In Go, we can create a map with a key of type bool using the following syntax:
main.go36 chars2 lines
Here, valueType
denotes the type of the values that will be stored in the map.
Example:
main.go167 chars6 lines
In the above example, we have created a map with a bool key and string value. We are adding two key-value pairs to the map and then printing them using their respective keys. Here, true
and false
are the two keys of the map and John
and Jane
are the corresponding values.
gistlibby LogSnag