I'm writing type assertion helper method which accepts an interface{}
and returns string
along with map[string]interface{}
. I'm returning both objects within a case statement. Why is it asking for return at end of function? Am i missing a break?
func typeAssertionHelper(r interface{}) (string, map[string]interface{}) {
switch g := r.(type) {
case string:
return g, nil
case []interface{}:
for _, v := range g {
switch s := v.(type) {
case string:
return s, nil
case map[string]interface{}:
return "", s
}
}
}
// missing return end of function
}