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
+4.4k Golang : A program that contain another program and executes it during run-time
+27.4k Golang : Move file to another directory
+17.5k Golang : Convert IPv4 address to decimal number(base 10) or integer
+5.2k Javascript : How to refresh page with JQuery ?
+6.8k Golang : How to iterate a slice without using for loop?
+21.9k Golang : Convert Unix timestamp to UTC timestamp
+6.5k Golang : constant 20013 overflows byte error message
+11.7k Golang : Flush and close file created by os.Create and bufio.NewWriter example
+4.9k Golang : Generate Interleaved 2 inch by 5 inch barcode
+11.5k Linux : How to install driver for 600Mbps Dual Band Wifi USB Adapter
+10.1k Golang : How to delete element(data) from map ?
+18k Golang : Send email with attachment