mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 21:27:31 +00:00
all: use syncs.AtomicValue
Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
@@ -9,7 +9,8 @@ import (
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"sync/atomic"
|
||||
|
||||
"tailscale.com/syncs"
|
||||
)
|
||||
|
||||
type Distro string
|
||||
@@ -28,14 +29,14 @@ const (
|
||||
WDMyCloud = Distro("wdmycloud")
|
||||
)
|
||||
|
||||
var distroAtomic atomic.Value // of Distro
|
||||
var distroAtomic syncs.AtomicValue[Distro]
|
||||
|
||||
// Get returns the current distro, or the empty string if unknown.
|
||||
func Get() Distro {
|
||||
d, ok := distroAtomic.Load().(Distro)
|
||||
if ok {
|
||||
if d, ok := distroAtomic.LoadOk(); ok {
|
||||
return d
|
||||
}
|
||||
var d Distro
|
||||
switch runtime.GOOS {
|
||||
case "linux":
|
||||
d = linuxDistro()
|
||||
|
@@ -9,7 +9,8 @@ import (
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
|
||||
"tailscale.com/syncs"
|
||||
)
|
||||
|
||||
// IsMobile reports whether this is a mobile client build.
|
||||
@@ -43,7 +44,7 @@ func IsSandboxedMacOS() bool {
|
||||
return strings.HasSuffix(exe, "/Contents/MacOS/Tailscale")
|
||||
}
|
||||
|
||||
var isMacSysExt atomic.Value // of bool
|
||||
var isMacSysExt syncs.AtomicValue[bool]
|
||||
|
||||
// IsMacSysExt whether this binary is from the standalone "System
|
||||
// Extension" (a.k.a. "macsys") version of Tailscale for macOS.
|
||||
@@ -51,7 +52,7 @@ func IsMacSysExt() bool {
|
||||
if runtime.GOOS != "darwin" {
|
||||
return false
|
||||
}
|
||||
if b, ok := isMacSysExt.Load().(bool); ok {
|
||||
if b, ok := isMacSysExt.LoadOk(); ok {
|
||||
return b
|
||||
}
|
||||
exe, err := os.Executable()
|
||||
|
Reference in New Issue
Block a user