After posting this, I found https://github.com/golang/go/issues/6591 which covers exactly my question. As penance, I've mailed https://go-review.googlesource.com/c/29592/ to get the ball rolling on updating the documentation.- elias
On Thursday, September 22, 2016 at 3:43:31 PM UTC+8, elias...@gmail.com wrote:After posting this, I found https://github.com/golang/go/issues/6591 which covers exactly my question. As penance, I've mailed https://go-review.googlesource.com/c/29592/ to get the ball rolling on updating the documentation.- elias
By read this issue thread, https://github.com/golang/go/issues/6591,
it looks the new docs changed to:The argument obj must be a pointer to an object allocated by callingThis didn't correct the document in principle.
new, by taking the address of a composite literal, or by taking the
address of a local variable.
It looks the example provided in this issue has not been valid for newer go versions, at least for go 1.5.3+.
https://play.golang.org/p/v8810GsAzF
In fact, for go 1.5.3+, the argument obj can also be pointers to package level variables.
On Sat, Oct 1, 2016 at 8:27 AM, T L <tapi...@gmail.com> wrote:
On Thursday, September 22, 2016 at 3:43:31 PM UTC+8, elias...@gmail.com wrote:After posting this, I found https://github.com/golang/go/issues/6591 which covers exactly my question. As penance, I've mailed https://go-review.googlesource.com/c/29592/ to get the ball rolling on updating the documentation.- elias
By read this issue thread, https://github.com/golang/go/issues/6591,
it looks the new docs changed to:The argument obj must be a pointer to an object allocated by callingThis didn't correct the document in principle.
new, by taking the address of a composite literal, or by taking the
address of a local variable.
It looks the example provided in this issue has not been valid for newer go versions, at least for go 1.5.3+.
https://play.golang.org/p/v8810GsAzF
In fact, for go 1.5.3+, the argument obj can also be pointers to package level variables.That won't work. Because package level variables are never GC'ed, so SetFinalizer will beno-op for them. Therefore the docs is correct as is.
On Sat, Oct 1, 2016 at 8:27 AM, T L <tapi...@gmail.com> wrote:
On Thursday, September 22, 2016 at 3:43:31 PM UTC+8, elias...@gmail.com wrote:After posting this, I found https://github.com/golang/go/issues/6591 which covers exactly my question. As penance, I've mailed https://go-review.googlesource.com/c/29592/ to get the ball rolling on updating the documentation.- elias
By read this issue thread, https://github.com/golang/go/issues/6591,
it looks the new docs changed to:The argument obj must be a pointer to an object allocated by calling
new, by taking the address of a composite literal, or by taking the
address of a local variable.