]> Cypherpunks repositories - gostls13.git/commit
weak: align weak.Pointer documentation with runtime.AddCleanup
authorMichael Anthony Knyszek <mknyszek@google.com>
Sat, 7 Dec 2024 02:58:00 +0000 (02:58 +0000)
committerGopher Robot <gobot@golang.org>
Mon, 9 Dec 2024 18:29:19 +0000 (18:29 +0000)
commit07398d2e57ac5df6f95b0344252f1560376328f3
tree4e2715e4490ae3e66ea650b0569fa458bff41124
parente3e1d735287a3bab5b060415513bd64785c4e209
weak: align weak.Pointer documentation with runtime.AddCleanup

In hindsight, I think the "advice" I wrote is a bit heavy-handed and
better suited for something like the GC guide. Listing the use-cases
seems good, and all the possible things that go wrong seems to do the
trick in terms of deterrence, like it does with finalizers.

Also, include some points I missed, like the tiny allocator warning and
the fact that weak pointers are not guaranteed to ever return nil.

Also, a lot of this actually shouldn't have been in the package docs.
Many of the warnings only apply to weak pointers, but not other data
structures that may live in this package in the future, like weak-keyed
maps.

Change-Id: Id245661540ffd93de4b727cd272284491d085c1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/634376
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
src/weak/doc.go
src/weak/pointer.go