Hi all,

I've read a lot about escape analysis in golang, but still couldn't find an 
answer to this question
here is the sample <https://play.golang.org/p/GWotXWY0ksC>:

package main

type IMeta interface {
    Index() int
}

type Builder struct {
    buf  []byte
    meta IMeta
}

func main() {
    var buffer [512]byte

    b := Builder{buffer[:0], nil}

    if b.meta != nil {
        b.meta.Index()
    }
}

escape analyzer says:
.\main.go:15:21: buffer escapes to heap
.\main.go:13:6: moved to heap: buffer
<autogenerated>:1:0: leaking param: .this

Could anyone please clarify why local buffer escapes here?

Thx in advance

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to