To retrieve the values of a map in Go, you can use the range keyword to iterate over the map and retrieve each value.
main.go150 chars7 lines
In this example, we define a map with string keys and integer values. We then use the range keyword to iterate over the map and retrieve the values. Within the loop, we print the value of each key-value pair.
Note that we use the blank identifier _
to ignore the key in this case, since we are only interested in the values of the map.
This will output:
main.go6 chars4 lines
gistlibby LogSnag