I wanted sorted key of a map, of course I can do this.

// myMap => map[string]map[string]Something
keys := make([]string, 0)
for k := range myMap {
    keys = append(keys, k)
}

but what I want is make this a function.

func sortedKeys(m map[string]interface{}) {
    keys := make([]string, 0)
    for k := range m {
        keys = append(keys, k)
    }
}

so I can use the function inside of a template. (because I don't want add 
too much code in template)

but it seems the argument is not automatically converted.

sortedKeys(myMap) // error

manual type cast `map[string]interface{}(myMap)` also not working.

is there a way of doing this? 

Thank you.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to