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
+8.6k Your page has meta tags in the body instead of the head
+12.8k Golang : Drop cookie to visitor's browser and http.SetCookie() example
+13.3k Golang : Convert(cast) uintptr to string example
+10.2k Golang : Read file and convert content to string
+4.6k Java : Generate multiplication table example
+22.2k Fix "Failed to start php5-fpm.service: Unit php5-fpm.service is masked."
+18.3k Golang : Convert IPv4 address to decimal number(base 10) or integer
+33.9k Golang : How to check if slice or array is empty?
+16.6k Golang : Loop each day of the current month example
+11.4k Golang : Proper way to test CIDR membership of an IP 4 or 6 address example
+22.2k Golang : Use TLS version 1.2 and enforce server security configuration over client
+9.9k Golang : Qt get screen resolution and display on center example