I am doing some unit tests and would like to fill out all the variables in a struct. The map[string][]byte
data type is giving me trouble though 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 to correct the mistake.
map["k1":[1,2,3] "k2":[4,5,6] "k3":[7,8,9]]
The error message:
expected type, found "k1"
Any ideas on what is wrong with my mock output?
CodePudding user response:
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},
}