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
+3 -4
View File
@@ -50,7 +50,6 @@ import (
"tailscale.com/types/key"
"tailscale.com/types/netmap"
"tailscale.com/types/opt"
"tailscale.com/types/ptr"
"tailscale.com/util/must"
"tailscale.com/util/set"
)
@@ -730,8 +729,8 @@ func TestConfigFileAuthKey(t *testing.T) {
must.Do(os.WriteFile(authKeyFile, fmt.Appendf(nil, "%s\n", authKey), 0666))
must.Do(os.WriteFile(n1.configFile, must.Get(json.Marshal(ipn.ConfigVAlpha{
Version: "alpha0",
AuthKey: ptr.To("file:" + authKeyFile),
ServerURL: ptr.To(n1.env.ControlServer.URL),
AuthKey: new("file:" + authKeyFile),
ServerURL: new(n1.env.ControlServer.URL),
})), 0644))
d1 := n1.StartDaemon()
@@ -2232,7 +2231,7 @@ func TestC2NDebugNetmap(t *testing.T) {
// Send a delta update to n1, marking node 0 as online.
env.Control.AddRawMapResponse(nodes[1].Key, &tailcfg.MapResponse{
PeersChangedPatch: []*tailcfg.PeerChange{{
NodeID: nodes[0].ID, Online: ptr.To(true),
NodeID: nodes[0].ID, Online: new(true),
}},
})
@@ -38,7 +38,6 @@ import (
"tailscale.com/types/key"
"tailscale.com/types/logger"
"tailscale.com/types/opt"
"tailscale.com/types/ptr"
"tailscale.com/util/httpm"
"tailscale.com/util/mak"
"tailscale.com/util/must"
@@ -1337,9 +1336,9 @@ func (s *Server) MapResponse(req *tailcfg.MapRequest) (res *tailcfg.MapResponse,
}
if masqIP := nodeMasqs[p.Key]; masqIP.IsValid() {
if masqIP.Is6() {
p.SelfNodeV6MasqAddrForThisPeer = ptr.To(masqIP)
p.SelfNodeV6MasqAddrForThisPeer = new(masqIP)
} else {
p.SelfNodeV4MasqAddrForThisPeer = ptr.To(masqIP)
p.SelfNodeV4MasqAddrForThisPeer = new(masqIP)
}
}
p.IsJailed = jailed[p.Key]
+1 -3
View File
@@ -8,8 +8,6 @@ import (
"reflect"
"testing"
"time"
"tailscale.com/types/ptr"
)
// IsZeroable is the interface for things with an IsZero method.
@@ -60,7 +58,7 @@ func CheckIsZero[T IsZeroable](t testing.TB, nonzeroValues map[reflect.Type]any)
case timeType:
return reflect.ValueOf(time.Unix(1704067200, 0))
case timePtrType:
return reflect.ValueOf(ptr.To(time.Unix(1704067200, 0)))
return reflect.ValueOf(new(time.Unix(1704067200, 0)))
}
switch ty.Kind() {