Why does the parameter passed to fmt.Print escape to heap?
// 11.go
package main
import "fmt"
import "math/rand"
func f1(v int) {
fmt.Print(v) // v escapes to heap
}
var a int
func f2(v int) {
a = rand.Intn(v) // v doesn't escape
}
func main() {
}
/*
> go build -gcflags=-m 11.go
# command-line-arguments
./11.go:15: can inline main
./11.go:7: v escapes to heap
./11.go:7: f1 ... argument does not escape
*/
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.