Ensure that EnvVar struct field exists before interrogating it
Otherwise you end up with `<invalid Value>` which, in practice, would probably work, but this is cleaner.
This commit is contained in:
parent
d60469024a
commit
168c95418e
@ -79,9 +79,12 @@ func (c *Context) IsSet(name string) bool {
|
||||
return
|
||||
}
|
||||
|
||||
envVars := reflect.ValueOf(f).FieldByName("EnvVar").String()
|
||||
envVarValue := reflect.ValueOf(f).FieldByName("EnvVar")
|
||||
if !envVarValue.IsValid() {
|
||||
return
|
||||
}
|
||||
|
||||
eachName(envVars, func(envVar string) {
|
||||
eachName(envVarValue.String(), func(envVar string) {
|
||||
envVar = strings.TrimSpace(envVar)
|
||||
if envVal := os.Getenv(envVar); envVal != "" {
|
||||
c.setFlags[name] = true
|
||||
|
Loading…
Reference in New Issue
Block a user