9func LoadOptionsFromEnv(options interface{}, cfg map[string]interface{}) {
10 val := reflect.ValueOf(options).Elem()
12 for i := 0; i < typ.NumField(); i++ {
13 // pull out the struct tags:
14 // flag - the name of the command line flag
15 // deprecated - (optional) the name of the deprecated command line flag
16 // cfg - (optional, defaults to underscored flag) the name of the config file option
18 flagName := field.Tag.Get("flag")
19 envName := field.Tag.Get("env")
20 cfgName := field.Tag.Get("cfg")
21 if cfgName == "" && flagName != "" {
22 cfgName = strings.Replace(flagName, "-", "_", -1)
24 if envName == "" || cfgName == "" {
25 // resolvable fields must have the `env` and `cfg` struct tag
28 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