In Go language, a map is a powerful, ingenious, and a versatile data structure. Golang Maps is a collection of unordered pairs of key-value. It is widely used because it provides fast lookups and values that can retrieve, update or delete with the help of keys.
In Go language, you are allowed to compare two maps with each other using DeepEqual() function provided by the reflect package. This function returns true if both the maps satisfy the following conditions:
- Both maps are nil or non-nil.
- Both maps have same length.
- Both maps are the same map object or their corresponding keys map to deeply equal values.
Otherwise, this function returns false.
Here, a and b are maps, and this function checks whether a and b are deeply equal or not, then return boolean type result.
Is Map 1 is equal to Map 2: false Is Map 1 is equal to Map 3: true Is Map 1 is equal to Map 4: false Is Map 2 is equal to Map 3: false Is Map 3 is equal to Map 3: false Is Map 4 is equal to Map 4: true Is Map 2 is equal to Map 4: false
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.