Original post

Complete Code : https://play.golang.org/p/bctvsy7ARqS

package main

import (
“fmt”
)

type Plan struct {
BufferMeasures map[string]*ItemSiteMeasure
}
type ItemSiteMeasure struct {
itemtest string
}

func main() {

fmt.Println("start")
var buff Plan
buff.AddBuffer()
fmt.Println("end")

}

func (p *Plan) AddBuffer() {
fmt.Println(“method start”)
p.BufferMeasures[“itmsit1”] = &ItemSiteMeasure{itemtest: “item1”}
fmt.Println(“obj values : “, p.BufferMeasures)
fmt.Println(“method end”)
}

Error /output:

start
method start
panic: assignment to entry in nil map

goroutine 1 [running]:
main.(*Plan).AddBuffer(0xc000068f50)
/tmp/sandbox633108119/prog.:29 +0xe8
main.main()
/tmp/sandbox633108119/prog.go:20 +0x90