Documentation
¶
Overview ¶
package maps contains utilities to handle common map operations
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetIString ¶
IMapGetString gets a string out of a map of interfaces keyed by a string. Returns the string and true if found, or an empty string and false if not, or the found item was not a string.
func GetJsonFloat ¶
IMapGetJsonFloat gets a float64 out of a map of interfaces that were unmarshalled from json. Json unmarshalling creates json numbers, and these have to be coerced into integers or floats. Returns an int and true if found, and a zero and false if not, or the found item was not a coercible number.
func GetJsonInt ¶
IMapGetJsonInt gets an integer out of a map of interfaces that were unmarshalled from json. Json unmarshalling creates json numbers, and these have to be coerced into integers or floats. Returns an int and true if found, and a zero and false if not, or the found item was not a coercible number.
func SortedKeys ¶ added in v0.2.0
func SortedKeys(i interface{}) []string
SortedKeys returns the keys of any map that uses strings as keys, sorted alphabetically. Note that even though we are using reflection here, this process is very fast compared to not using reflection, so feel free to use it in all situations.
Example ¶
m := map[string]int{
"One": 1,
"Two": 2,
"Three": 3,
}
k := SortedKeys(m)
fmt.Print(k)
Output: [One Three Two]
Types ¶
This section is empty.