I see some code samples with constructs like this:
type point struct {
x, y int
}
func newPoint() *point {
return &point{10, 20}
}
The Golang "Documentation states that it's perfectly legal to return a pointer to local variable." As I read here
https://groups.google.com/forum/?fromgroups=#!topic/golang-nuts/EYUuead0LsY
I looks like the compiler sees you return the address and just makes it on the heap for you. This is a common idiom in Go.