Golang : Of hash table and hash map
A short note for myself. Was looking to build a knowledge base consisting of a keyword or key string and then lookup for the nearest possible string answer.
This kind situation calls for a hash table and was looking for hash table equivalent in Golang and ....just found out that Golang's map is equivalent to other programming languages hash map or hash table! #facepalm to myself.
In general, a hash map is useful as it offers fast lookups, adds, and deletes. In Golang, the built-in map type has these properties.
NOTE : Map types are reference types, like pointers or slices, and so the value of m above is nil; it doesn't point to an initialized map. A nil map behaves like an empty map when reading, but attempts to write to a nil map will cause a runtime panic; don't do that. To initialize a map, use the built in make function:
m = make(map[string]int)
Reference :
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+5.8k Golang : Warp text string by number of characters or runes example
+8.3k Golang : Web(Javascript) to server-side websocket example
+8.6k Golang : interface - when and where to use examples
+12.1k CodeIgniter : "Fatal error: Cannot use object of type stdClass as array" message
+4.9k Golang : Denco multiplexer example
+4.5k Golang : Frobnicate or tweaking a string example
+14.1k Golang : Get digits from integer before and after given position example
+8.3k Golang : How to control fmt or log print format?
+5.1k Golang : How to write backslash in string?
+9k Golang : Simple Jawi(Yawi) to Rumi(Latin/Romanize) converter
+9.4k Golang : ISO8601 Duration Parser example
+11.2k Golang : Display list of countries and ISO codes