Reputation: 13698
I have:
type Foo struct{
Name string
Hands map[string]string
}
aFoo := Foo{
Name: "Henry"
Hands: ???????
}
I want to set some values for "Hands", but I cannot get the syntax correct. As an example, I want to use a map like:
"Left":"broken"
"Right":"missing thumb"
Upvotes: 0
Views: 88
Reputation: 99274
Foo{
Name: "Henry",
Hands: make(map[string]string),
}
aFoo.Hands["Left"] = "broken"
// or just
Foo{
Name: "Henry",
Hands: map[string]string{"Left": "broken", "Right": "missing thumb"},
}
Upvotes: 2