You need to assign a value (your struct) to your key:
type S struct {
pos int
n int
}
type Words map[string]S
func main() {
w := make(Words)
s := S{pos: 1, n: 2}
w["abc"] = s
fmt.Println(w)
}
See this <kbd>play.golang.org</kbd> example.
Output:
map[abc:{1 2}]
See more at "Go maps in action".
Then you can retrieve your value and assign:
sbis := w["abc"]
sbis.pos = 11
fmt.Println(sbis)
Output:
{11 2}
In his example, OneOfOne proposes a getter in order to assign pos quicker, but creating if needed the right value (that is an instance of the struct):
func (w Words) get(s string) (p *ps) {
if p = w[s]; p == nil {
p = &ps{}
w[s] = p
}
return
}
That allows:
w := Words{}
w.get("abc").pos = 10