Don't switch on a single case

Signed-off-by: Nikolay Edigaryev <edigaryev@gmail.com>
This commit is contained in:
Nikolay Edigaryev
2021-02-18 01:43:23 +03:00
parent 3e168b19f2
commit e022c19753

View File

@ -12,8 +12,7 @@ import (
) )
func IsSimpleType(f reflect.Value) bool { func IsSimpleType(f reflect.Value) bool {
switch f.Interface().(type) { if _, ok := f.Interface().(fmt.Stringer); ok {
case fmt.Stringer:
return true return true
} }
@ -26,9 +25,8 @@ func IsSimpleType(f reflect.Value) bool {
} }
func SimpleTypeToParam(f reflect.Value) string { func SimpleTypeToParam(f reflect.Value) string {
switch cast := f.Interface().(type) { if s, ok := f.Interface().(fmt.Stringer); ok {
case fmt.Stringer: return s.String()
return cast.String()
} }
switch f.Kind() { switch f.Kind() {