Maps Implementation

Learn how maps are implemented in Go.

struct{} type

Go doesn’t have a set data structure (something like a map with keys but without values, as implemented as std::set in C++ or HashSet in C#). It’s easy enough to use a map instead. One small trick is to use a struct{} type as a map value:

Get hands-on with 1200+ tech skills courses.