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
+6.3k Javascript : Generate random key with specific length
+6.4k Golang : How to search a list of records or data structures
+8.3k Golang: Prevent over writing file with md5 hash
+7.9k Golang : Lock executable to a specific machine with unique hash of the machine
+13.5k Facebook PHP getUser() returns 0
+8.3k Golang : Add build version and other information in executables
+39.7k Golang : Remove dashes(or any character) from string
+14.8k Golang : Get URI segments by number and assign as variable example
+12.7k Golang : Remove or trim extra comma from CSV
+11.1k Golang : Web routing/multiplex example
+9.8k Golang : Resumable upload to Google Drive(RESTful) example
+11.7k Golang : Find age or leap age from date of birth example