Hi,
I'm a newbie and trying to understand how I can convert an argument of type interface {} back to a map so that I can iterate over the map.
Heres my sample code:
func SampleFunc(result interface{}) {
// How to iterate over the result?
// Below code gives "cannot range over result (type interface {})" error
for k, v := range result {
// do something
}
}
func SomeOtherFunc() {
tempMap := make(map[string]interface{})
tempMap["aaa"] = "bbb"
resultArray := make([]map[string]interface{}, 0)
resultArray = append(result, rm)
SampleFunc(resultArray)
}
How do I convert the interface back to the map array and iterate over the map to access the key-value pairs?
Thanks for all the help!