'In Go, how to type a parameter of a map of any type of key and any pointer of value? [duplicate]
Can I have a utility function that can count the null values in maps regardless of what type the value might point to?
func countMapNils(aMap map[string]*????????) int {
nilCount := 0
for _, value := range aMap {
if value == nil {
nilCount++
}
}
return nilCount
}
I have tried
func f(map[string]interface{})
and
func f(map[string]*interface{})
and GoLand reports that
"Cannot use 'countryRefFares' (type map[string]*redis.RefFare) as the type map[string]*interface{}"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
