To create a map with a value of type array in Go, you can use the following code:
main.go248 chars12 lines
In this example, we have initialized a map myMap
which has string
keys and array
values of size 3. We have added a value to the map with key "myKey"
, and assigned an array {1, 2, 3}
as the value.
To access values in the map, you can use the key to retrieve the corresponding value, as shown in the example. Finally, we output the value of the key "myKey"
to the console, which will be the array {1, 2, 3}
.
gistlibby LogSnag