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:
committed by
Brad Fitzpatrick
parent
8cfbaa717d
commit
2a64c03c95
@@ -23,7 +23,6 @@ import (
|
||||
"tailscale.com/tailcfg"
|
||||
"tailscale.com/types/lazy"
|
||||
"tailscale.com/types/opt"
|
||||
"tailscale.com/types/ptr"
|
||||
"tailscale.com/util/cloudenv"
|
||||
"tailscale.com/util/dnsname"
|
||||
"tailscale.com/util/lineiter"
|
||||
@@ -93,8 +92,8 @@ func condCall[T any](fn func() T) T {
|
||||
}
|
||||
|
||||
var (
|
||||
lazyInContainer = &lazyAtomicValue[opt.Bool]{f: ptr.To(inContainer)}
|
||||
lazyGoArchVar = &lazyAtomicValue[string]{f: ptr.To(goArchVar)}
|
||||
lazyInContainer = &lazyAtomicValue[opt.Bool]{f: new(inContainer)}
|
||||
lazyGoArchVar = &lazyAtomicValue[string]{f: new(goArchVar)}
|
||||
)
|
||||
|
||||
type lazyAtomicValue[T any] struct {
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
"tailscale.com/types/ptr"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -19,7 +18,7 @@ func init() {
|
||||
}
|
||||
|
||||
var (
|
||||
lazyOSVersion = &lazyAtomicValue[string]{f: ptr.To(osVersionDarwin)}
|
||||
lazyOSVersion = &lazyAtomicValue[string]{f: new(osVersionDarwin)}
|
||||
)
|
||||
|
||||
func packageTypeDarwin() string {
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"os/exec"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
"tailscale.com/types/ptr"
|
||||
"tailscale.com/version/distro"
|
||||
)
|
||||
|
||||
@@ -22,8 +21,8 @@ func init() {
|
||||
}
|
||||
|
||||
var (
|
||||
lazyVersionMeta = &lazyAtomicValue[versionMeta]{f: ptr.To(freebsdVersionMeta)}
|
||||
lazyOSVersion = &lazyAtomicValue[string]{f: ptr.To(osVersionFreeBSD)}
|
||||
lazyVersionMeta = &lazyAtomicValue[versionMeta]{f: new(freebsdVersionMeta)}
|
||||
lazyOSVersion = &lazyAtomicValue[string]{f: new(osVersionFreeBSD)}
|
||||
)
|
||||
|
||||
func distroNameFreeBSD() string {
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
"tailscale.com/types/ptr"
|
||||
"tailscale.com/util/lineiter"
|
||||
"tailscale.com/version/distro"
|
||||
)
|
||||
@@ -26,8 +25,8 @@ func init() {
|
||||
}
|
||||
|
||||
var (
|
||||
lazyVersionMeta = &lazyAtomicValue[versionMeta]{f: ptr.To(linuxVersionMeta)}
|
||||
lazyOSVersion = &lazyAtomicValue[string]{f: ptr.To(osVersionLinux)}
|
||||
lazyVersionMeta = &lazyAtomicValue[versionMeta]{f: new(linuxVersionMeta)}
|
||||
lazyOSVersion = &lazyAtomicValue[string]{f: new(osVersionLinux)}
|
||||
)
|
||||
|
||||
type versionMeta struct {
|
||||
|
||||
@@ -9,14 +9,13 @@ import (
|
||||
"runtime"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
"tailscale.com/types/ptr"
|
||||
)
|
||||
|
||||
func init() {
|
||||
unameMachine = lazyUnameMachine.Get
|
||||
}
|
||||
|
||||
var lazyUnameMachine = &lazyAtomicValue[string]{f: ptr.To(unameMachineUnix)}
|
||||
var lazyUnameMachine = &lazyAtomicValue[string]{f: new(unameMachineUnix)}
|
||||
|
||||
func unameMachineUnix() string {
|
||||
switch runtime.GOOS {
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
"golang.org/x/sys/windows/registry"
|
||||
"tailscale.com/types/ptr"
|
||||
"tailscale.com/util/winutil"
|
||||
"tailscale.com/util/winutil/winenv"
|
||||
)
|
||||
@@ -23,9 +22,9 @@ func init() {
|
||||
}
|
||||
|
||||
var (
|
||||
lazyDistroName = &lazyAtomicValue[string]{f: ptr.To(distroNameWindows)}
|
||||
lazyOSVersion = &lazyAtomicValue[string]{f: ptr.To(osVersionWindows)}
|
||||
lazyPackageType = &lazyAtomicValue[string]{f: ptr.To(packageTypeWindows)}
|
||||
lazyDistroName = &lazyAtomicValue[string]{f: new(distroNameWindows)}
|
||||
lazyOSVersion = &lazyAtomicValue[string]{f: new(osVersionWindows)}
|
||||
lazyPackageType = &lazyAtomicValue[string]{f: new(packageTypeWindows)}
|
||||
)
|
||||
|
||||
func distroNameWindows() string {
|
||||
|
||||
Reference in New Issue
Block a user