jessevdk / go-flags

go command line option parser
http://godoc.org/github.com/jessevdk/go-flags
BSD 3-Clause "New" or "Revised" License
2.59k stars 308 forks source link

Improper octal conversion due to strconv.ParseInt() #412

Open dwhittle-sfdc opened 2 months ago

dwhittle-sfdc commented 2 months ago

I have a case where I want to pass *nix file permissions as a command line option in standard octal format (e.g. 0600). Unfortunately it looks like the package is using strconv.ParseInt() to handle int options and it is not doing the correct thing.

Here is a basic example:

Sample code:

package main

import (
    "fmt"
    "strconv"
)

func main() {
    fmt.Println(int(0600))
    fmt.Println(strconv.ParseInt("0600", 10, 32))
}

Result:

384
600 <nil>

When the octal is converted to an int, 384 is the expected result in this case.

I suppose this is really a Go issue and I should go submit a bug to them, but is this something you think could be fixed here in your package. I'd be happy to submit a PR to patch it, but I have to jump through corporate hoops to get approval first :roll_eyes: I'd rather not bother with that if it's something you wouldn't consider accepting.