Dereference Flags if they are pointers

When checking if environment variables are set.

We don't support pointer flags currently (though this is the default in
the `v2` branch), but this fixes #516
This commit is contained in:
Jesse Szwedko 2016-09-08 21:10:46 -07:00
parent c723b19a84
commit e7b1833f53

View File

@ -79,7 +79,12 @@ func (c *Context) IsSet(name string) bool {
return
}
envVarValue := reflect.ValueOf(f).FieldByName("EnvVar")
val := reflect.ValueOf(f)
if val.Kind() == reflect.Ptr {
val = val.Elem()
}
envVarValue := val.FieldByName("EnvVar")
if !envVarValue.IsValid() {
return
}