Hi,
$ go run -gcflags="-m" main.go
# command-line-arguments
./main.go:39:13: inlining call to fmt.Println
./main.go:14:6: can inline (*myFuncImplStruct).myFunc-fm
./main.go:28:23: leaking param: f
./main.go:29:7: &myFuncContainer literal escapes to heap
./main.go:35:7: &myFuncImplStruct literal escapes to heap
./main.go:37:26: m.myFunc escapes to heap
./main.go:39:13: []interface {} literal does not escape
<autogenerated>:1: .this does not escape
The asm code shows that there's a call to runtime.newobject which I think allocs a new object for m.myFunc:
I would like to know:
1. How can a function "escapes to heap"? Isn't it a pointer to the code area?
2. Why does the receiver function "escapes to heap" while the normal function does not?
3. What's the new object allocated?
Thanks very much!