9type EnvOptions map[string]interface{}
11func (cfg EnvOptions) LoadEnvForStruct(options interface{}) {
12 val := reflect.ValueOf(options).Elem()
14 for i := 0; i < typ.NumField(); i++ {
15 // pull out the struct tags:
16 // flag - the name of the command line flag
17 // deprecated - (optional) the name of the deprecated command line flag
18 // cfg - (optional, defaults to underscored flag) the name of the config file option
20 flagName := field.Tag.Get("flag")
21 envName := field.Tag.Get("env")
22 cfgName := field.Tag.Get("cfg")
23 if cfgName == "" && flagName != "" {
24 cfgName = strings.Replace(flagName, "-", "_", -1)
26 if envName == "" || cfgName == "" {
27 // resolvable fields must have the `env` and `cfg` struct tag
30 v := os.Getenv(envName)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list