Browse Source

types/lazy: document difference from sync.OnceValue

Updates #8419
Updates github.com/golang#62202

Change-Id: I0c082c4258fb7a95a17054f270dc32019bcc7581
Signed-off-by: Brad Fitzpatrick <[email protected]>
Brad Fitzpatrick 5 months ago
parent
commit
f208bf8cb1
1 changed files with 3 additions and 0 deletions
  1. 3 0
      types/lazy/lazy.go

+ 3 - 0
types/lazy/lazy.go

@@ -23,6 +23,9 @@ var nilErrPtr = ptr.To[error](nil)
 // Recursive use of a SyncValue from its own fill function will deadlock.
 //
 // SyncValue is safe for concurrent use.
+//
+// Unlike [sync.OnceValue], the linker can do better dead code elimination
+// with SyncValue. See https://github.com/golang/go/issues/62202.
 type SyncValue[T any] struct {
 	once sync.Once
 	v    T