Closed isoldmysoull closed 2 weeks ago
The following code:
package main import ( "fmt" "github.com/alecthomas/kong" kongyaml "github.com/alecthomas/kong-yaml" "os" "strings" ) type CLI struct { UserEnumType int `required:"" enum:"1,2,3,4,5"` } func main() { data := `user-enum-type: 44423` resolver, err := kongyaml.Loader(strings.NewReader(data)) if err != nil { fmt.Printf("Err: %v\n", err) os.Exit(1) } var cli CLI parser, err := kong.New(&cli, kong.Resolvers(resolver)) if err != nil { fmt.Printf("Err: %v\n", err) os.Exit(1) } _, err = parser.Parse(nil) if err != nil { fmt.Printf("Err: %v\n", err) os.Exit(1) } fmt.Printf("UserEnumType: %d\n", cli.UserEnumType) }
returns an weird error like this:
Err: --user-enum-type must be one of "1","2","3","4","5" but got '궇'
it should be but got '44423'. this only happens to INT. strings works fine.
but got '44423'
The following code:
returns an weird error like this:
it should be
but got '44423'
. this only happens to INT. strings works fine.