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
+9.1k Golang : Text file editor (accept input from screen and save to file)
+22.9k Golang : Call function from another package
+19.3k Golang : Convert date string to variants of time.Time type examples
+15.7k Golang : How to tell if a file is compressed either gzip or zip ?
+18.4k Golang : How to get time from unix nano example
+32.4k Golang : Call a function after some delay(time.Sleep and Tick)
+3.2k Javascript : Empty an array example
+23.6k Golang : Get current file path of a file or executable
+5.1k Golang : Scan forex opportunities by Bollinger bands
+4.8k Golang : Fix opencv.LoadHaarClassifierCascade The node does not represent a user object error
+11k Golang : Send data to /dev/null a.k.a blackhole with ioutil.Discard
+10.5k Golang : Convert decimal number(integer) to IPv4 address