What do you mean by escape? It prints the ptr to y, like the previous 
prints the ptr to x. Y is the same pointer throughout, as it should be.

On Tuesday, 1 June 2021 at 14:51:50 UTC+1 tapi...@gmail.com wrote:

>
> package main
>
> func newIntPtr(n int) *int {
>     return &n
> }
>
> func main() {
>     x := newIntPtr(3)
>     y := newIntPtr(5)
>     c := make(chan bool)
>     go func() {
>         *y++
>         close(c)
>     }()
>     <-c
>     println(*x, *y)
>     println(&x)
>     //println(&y) // This line makes y 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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/5d84ba06-ec44-477d-a90e-b67dc14535fan%40googlegroups.com.

Reply via email to