I have the following map
whose key type is an anonymous struct
:
var data map[struct{ pID, bID int }]string
Question: How would I go about constructing a key to actually get/set a value in data
?
I've tried these, which all result in compiler errors:
data[{1,2}] = "ok"
data[{pID: 1, bID 2}] = "ok"
It seems I cannot form a compound literal without having the type name, but there is no type name.
This related question uses an anymous struct
as the value of a map
, but not the key: