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
+19.3k Golang : Close channel after ticker stopped example
+13.9k Golang : Chunk split or divide a string into smaller chunk example
+8.2k Golang : Ackermann function example
+12.8k Swift : Convert (cast) Int to String ?
+9.4k Golang : How to generate Code 39 barcode?
+7.1k Golang : Calculate how many weeks left to go in a given year
+35.7k Golang : Save image to PNG, JPEG or GIF format.
+21.5k Golang : Upload big file (larger than 100MB) to AWS S3 with multipart upload
+18.1k Golang : Get path name to current directory or folder
+9.5k Golang : Detect number of active displays and the display's resolution
+28.2k Golang : Read, Write(Create) and Delete Cookie example
+5.5k Unix/Linux/MacOSx : Get local IP address