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
+16.8k Golang : XML to JSON example
+5.3k PHP : Fix Call to undefined function curl_init() error
+9.8k Golang : Find and replace data in all files recursively
+4.9k Golang : Check if a word is countable or not
+7.3k Golang : Handling Yes No Quit query input
+17.7k Golang : Get all upper case or lower case characters from string example
+6.1k WARNING: UNPROTECTED PRIVATE KEY FILE! error message
+5.9k Golang : Get missing location after unmarshal binary and gob decode time.
+10.9k Golang : Web routing/multiplex example
+18.9k Golang : Get host name or domain name from IP address
+20.2k Golang : Pipe output from one os.Exec(shell command) to another command
+4.8k Golang : Get a list of crosses(instruments) available to trade from Oanda account