I am trying to create a function that could accept following
*struct
[]*struct
map[string]*struct
Here struct could be any struct not just a sp
Another way to convert an interface{}
into a map
with the package reflect is with MapRange.
I quote:
MapRange returns a range iterator for a map. It panics if v's Kind is not Map.
Call Next to advance the iterator, and Key/Value to access each entry. Next returns false when the iterator is exhausted. MapRange follows the same iteration semantics as a range statement.
Example:
iter := reflect.ValueOf(m).MapRange()
for iter.Next() {
key := iter.Key().Interface()
value := iter.Value().Interface()
...
}