Take the following program as an example.
```go
c, err := getFtpConnection()
if err != nil {
return nil, err
}
go func(c2 *ftp.ServerConn) {
c2.List()
}(c)
// c will not be used later
```
Let's add the `move` function.
```go
// pointer is
func move[PT *any](pp *PT) (res PT) {
res = *pp
*pp = nil
return
}
```
```go
// Goroutine G1
c, err := getFtpConnection()
if err != nil {
return nil, err
}
go func(c2 *ftp.ServerConn) { // Goroutine G2
c2.List()
}(move(&c))
// c will not be used later
```
Would this `move` without runtime support make GC unable to reach the
object pointed by `c` scanning from the stack of goroutine G1 so that the
ownership of object is entirely moved to goroutine G2? With this ownership
transfering, freegc for `c2` in the end of goroutine G2 is feasible in
cross-goroutine reference case.
--
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].
To view this discussion visit
https://groups.google.com/d/msgid/golang-nuts/5c0b8aaf-8470-4de2-91f6-5d74e884dff3n%40googlegroups.com.