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
+12.6k Golang : Add ASCII art to command line application launching process
+6.7k Unix/Linux : How to fix CentOS yum duplicate glibc or device-mapper-libs dependency error?
+8.9k Golang : Build and compile multiple source files
+36.5k Golang : Display float in 2 decimal points and rounding up or down
+4.6k Facebook : How to place save to Facebook button on your website
+11.5k Golang : Fuzzy string search or approximate string matching example
+6k PageSpeed : Clear or flush cache on web server
+15.2k nginx: [emerg] unknown directive "ssl"
+18.3k Golang : Aligning strings to right, left and center with fill example
+13.4k Golang : Get user input until a command or receive a word to stop
+7.4k Golang : Detect sample rate, channels or latency with PortAudio
+12.2k Golang : Display list of countries and ISO codes