Only apply altsrc input source values when set

Closes #1373
This commit is contained in:
2022-04-25 20:43:43 -04:00
parent e3aa8d3246
commit efe04493fc
4 changed files with 101 additions and 100 deletions

View File

@@ -244,6 +244,19 @@ func (fsm *MapInputSource) Bool(name string) (bool, error) {
return false, nil
}
// IsSet returns the truth of the key's existence in the map
func (fsm *MapInputSource) IsSet(name string) bool {
if _, exists := fsm.valueMap[name]; exists {
return exists
}
if _, exists := nestedVal(name, fsm.valueMap); exists {
return exists
}
return false
}
func incorrectTypeForFlagError(name, expectedTypeName string, value interface{}) error {
valueType := reflect.TypeOf(value)
valueTypeName := ""