I'm trying to understand what the below code block does;
var cache = struct {
sync.Mutex
mapping map[string]string
} {
mapping: make(map[string]string),
}
I don't understand the presence of } {
or what the last line does.
I'm trying to understand what the below code block does;
var cache = struct {
sync.Mutex
mapping map[string]string
} {
mapping: make(map[string]string),
}
I don't understand the presence of } {
or what the last line does.
The text
struct {
sync.Mutex
mapping map[string]string
} {
mapping: make(map[string]string),
}
is a composite literal. The literal's type is the anonymous struct type:
struct {
sync.Mutex
mapping map[string]string
}
The literal's value is
{
mapping: make(map[string]string),
}