Source file src/weak/doc.go
1 // Copyright 2024 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 /* 6 Package weak provides weak pointers with the goal of memory efficiency. 7 The primary use-cases for weak pointers are for implementing caches, 8 canonicalization maps (like the unique package), and for tying together 9 the lifetimes of separate values. 10 11 ## Advice 12 13 This package is intended to target niche use-cases like the unique 14 package, not as a general replacement for regular Go pointers, maps, 15 etc. 16 Misuse of the structures in this package will generate unexpected and 17 hard-to-reproduce bugs. 18 Using the facilities in this package to try and resolve out-of-memory 19 issues and/or memory leaks is very likely the wrong answer. 20 21 The structures in this package are intended to be an implementation 22 detail of the package they are used by (again, see the unique package). 23 Avoid exposing weak structures across API boundaries, since that exposes 24 users of your package to the subtleties of this package. 25 */ 26 package weak 27