types/ptr: deprecate ptr.To, use Go 1.26 new

Updates #18682

Change-Id: I62f6aa0de2a15ef8c1435032c6aa74a181c25f8f
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2026-03-05 22:48:46 +00:00
committed by Brad Fitzpatrick
parent 8cfbaa717d
commit 2a64c03c95
96 changed files with 429 additions and 532 deletions
+1 -3
View File
@@ -6,8 +6,6 @@ package lazy
import (
"sync"
"sync/atomic"
"tailscale.com/types/ptr"
)
// DeferredInit allows one or more funcs to be deferred
@@ -91,7 +89,7 @@ func (d *DeferredInit) doSlow() (err *error) {
}()
for _, f := range d.funcs {
if err := f(); err != nil {
return ptr.To(err)
return new(err)
}
}
return nilErrPtr
+3 -5
View File
@@ -7,13 +7,11 @@ package lazy
import (
"sync"
"sync/atomic"
"tailscale.com/types/ptr"
)
// nilErrPtr is a sentinel *error value for SyncValue.err to signal
// that SyncValue.v is valid.
var nilErrPtr = ptr.To[error](nil)
var nilErrPtr = new(error(nil))
// SyncValue is a lazily computed value.
//
@@ -80,7 +78,7 @@ func (z *SyncValue[T]) GetErr(fill func() (T, error)) (T, error) {
// Update z.err after z.v; see field docs.
if err != nil {
z.err.Store(ptr.To(err))
z.err.Store(new(err))
} else {
z.err.Store(nilErrPtr)
}
@@ -145,7 +143,7 @@ func (z *SyncValue[T]) SetForTest(tb testing_TB, val T, err error) {
z.v = val
if err != nil {
z.err.Store(ptr.To(err))
z.err.Store(new(err))
} else {
z.err.Store(nilErrPtr)
}