To create a map with a value of type byte in Go, you can use the make
function with the map
keyword.
Here is an example:
main.go31 chars2 lines
This creates a map with string
keys and byte
values. You can then add key-value pairs to the map using the syntax mapName[key] = value
.
Here is an example of adding a key-value pair to the myMap
:
main.go19 chars2 lines
Now the map has one key-value pair, where the key is "key" and the value is the byte 123.
gistlibby LogSnag