更新若干功能
This commit is contained in:
21
machineid_other.go
Normal file
21
machineid_other.go
Normal file
@@ -0,0 +1,21 @@
|
||||
//go:build !windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// rawMachineID 读取 Linux/macOS 的机器标识;读不到时返回空串由调用方兜底。
|
||||
func rawMachineID() string {
|
||||
for _, p := range []string{"/etc/machine-id", "/var/lib/dbus/machine-id"} {
|
||||
if b, e := os.ReadFile(p); e == nil {
|
||||
if v := strings.TrimSpace(string(b)); v != "" {
|
||||
return v
|
||||
}
|
||||
}
|
||||
}
|
||||
// macOS 没有 machine-id 文件,退回 IOPlatformUUID 太重,直接用主机名兜底(由调用方哈希)。
|
||||
return ""
|
||||
}
|
||||
Reference in New Issue
Block a user