Documentation ¶
Overview ¶
Map functions such as deep copying and equality testing.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyMap ¶
Clones a map deeply using recursion.
Example ¶
Deep copying a map using recursion via CopyMap.
CopyMap was designed for use with deserialised JSONs hence the map[string]interface{} signature.
original := map[string]interface{}{ "hello": "world", "age": 20, "bald": false, "friends": []interface{}{ "Bob", "Jane", "John", "Mark", map[string]interface{}{ "name": "Gregor", "age": 31, "friends": []interface{}{ "Bill", "Bob", "Sarah", }, }, }, } // Clone the above map. clone := CopyMap(original) fmt.Println("Original:", original) fmt.Println("Clone:", clone)
Output: Original: map[age:20 bald:false friends:[Bob Jane John Mark map[age:31 friends:[Bill Bob Sarah] name:Gregor]] hello:world] Clone: map[age:20 bald:false friends:[Bob Jane John Mark map[age:31 friends:[Bill Bob Sarah] name:Gregor]] hello:world]
func JsonMapEqualTest ¶
Used in tests to check equality between two interface{}s.
This takes into account orderings of slices.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.