'How can I represent map[string][]byte? [closed]
I would like to create a map, but I am unsure of the syntax. The map[string][]byte
data type is giving me trouble, because I think that the example below should be what it should look like in order to appease the compiler, but I receive an error which is unclear about how it should be properly depicted.
map["k1":[1,2,3] "k2":[4,5,6] "k3":[7,8,9]]
The error message:
expected type, found "k1"
How can I fix the syntax?
Solution 1:[1]
You have bad syntax. You should initialize it and declare like below
x := map[string][]byte{
"k1": []byte{1, 2, 3},
"k2": []byte{4, 5, 6},
"k3": []byte{7, 8, 9},
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Armatorix |