Open donkeywon opened 3 months ago
To avoid tag conflicts with other third-party libraries like env
type Cfg struct { Path string `flag-short:"p" flag-long:"path" flag-description:"path to xxx"` }
cfg := &Cfg{} parser := flags.NewParser(cfg, flags.Default, flags.FlagTagPrefix("flag-")) parser.Parse()
2. support custom field tags name ```go type Cfg struct { Path string `flag-custom-short:"p" long:"path" description:"path to xxx"` } flagTags := flags.NewFlagTags() flagTags.Short = "flag-custom-short" cfg := &Cfg{} parser := flags.NewParser(cfg, flags.Default, flags.CustomFlagTags(flagTags)) parser.Parse()
To avoid tag conflicts with other third-party libraries like env
cfg := &Cfg{} parser := flags.NewParser(cfg, flags.Default, flags.FlagTagPrefix("flag-")) parser.Parse()