Hi, I noticed a "strange behaviour" with flags and environment variables. This is my configuration:
type Config struct {
MyRequiredField string `env:"MY_REQUIRED_FIELD" long:"my-required-field" required:"true"`
}
func GetConfig(args []string) Config {
var c Config
if _, err := flags.ParseArgs(&c, args); err != nil {
panic(err)
}
return c
}
Now, if I launch program both this way: go run my_program.go --my-required-field=, and this other MY_REQUIRED_FIELD= go run my_program.go I receive no errors.
I know that both flag (first case) and environment variable (second case) are passed to the program, but they are unset. Shouldn't this be an error?
Hi, I noticed a "strange behaviour" with flags and environment variables. This is my configuration:
Now, if I launch program both this way:
go run my_program.go --my-required-field=, and this otherMY_REQUIRED_FIELD= go run my_program.goI receive no errors.I know that both flag (first case) and environment variable (second case) are passed to the program, but they are unset. Shouldn't this be an error?