diff --git a/altsrc/map_input_source.go b/altsrc/map_input_source.go index abd989f0d4..1a76051e84 100644 --- a/altsrc/map_input_source.go +++ b/altsrc/map_input_source.go @@ -3,7 +3,6 @@ package altsrc import ( "fmt" "math" - "reflect" "strings" "time" @@ -471,11 +470,5 @@ func (fsm *MapInputSource) isSet(name string) bool { } func incorrectTypeForFlagError(name, expectedTypeName string, value interface{}) error { - valueType := reflect.TypeOf(value) - valueTypeName := "" - if valueType != nil { - valueTypeName = valueType.Name() - } - - return fmt.Errorf("Mismatched type for flag '%s'. Expected '%s' but actual is '%s'", name, expectedTypeName, valueTypeName) + return fmt.Errorf("Mismatched type for flag '%s'. Expected '%s' but actual is '%T'", name, expectedTypeName, value) } diff --git a/altsrc/map_input_source_test.go b/altsrc/map_input_source_test.go index cf399b5354..4d3514e962 100644 --- a/altsrc/map_input_source_test.go +++ b/altsrc/map_input_source_test.go @@ -1,6 +1,7 @@ package altsrc import ( + "fmt" "testing" "time" ) @@ -33,3 +34,8 @@ func TestMapInputSource_Int64Slice(t *testing.T) { expect(t, []int64{1, 2, 3}, d) expect(t, nil, err) } + +func TestMapInputSource_IncorrectFlagTypeError(t *testing.T) { + var testVal *bool + expect(t, incorrectTypeForFlagError("test", "bool", testVal), fmt.Errorf("Mismatched type for flag 'test'. Expected 'bool' but actual is '*bool'")) +}