alecthomas / kong

Kong is a command-line parser for Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ignore required field if struct already has a default value

kotyara85 opened this issue · comments

Hello,
Does kong support autoignore errors if struct field has required flag and already has a value?

type Config struct {
  AppName        string `kong:"required"`
}

func main() {
cfg := Config{}
cfg.AppName = "test"

kong.Parse(&cfg) will result into error -app-name flag is not set
}

Thanks

No, Kong initialises the structure to zeroes/defaults.