返回 DeepSeek-Reasonix
devinfo_linux.go
根目录 / desktop / devinfo_linux.go
1 package main
2
3 import (
4 "os"
5 "strings"
6 )
7
8 func readOr(path string) string {
9 b, err := os.ReadFile(path)
10 if err != nil {
11 return ""
12 }
13 return string(b)
14 }
15
16 func platformOSVersion() string {
17 if name := parseOSReleasePrettyName(readOr("/etc/os-release")); name != "" {
18 return name
19 }
20 return "Linux"
21 }
22
23 func platformOSBuild() (int, int) { return 0, 0 }
24
25 func platformEnvironmentInfo() platformEnvironment {
26 release := parseOSRelease(readOr("/etc/os-release"))
27 distroID := boundedPlatformField(strings.ToLower(release["ID"]), 64)
28 if distroID == "" {
29 distroID = "unknown"
30 }
31 return platformEnvironment{
32 DistroID: distroID,
33 DistroVersion: boundedPlatformField(release["VERSION_ID"], 64),
34 KernelVersion: boundedPlatformField(readOr("/proc/sys/kernel/osrelease"), 128),
35 SessionType: linuxSessionType(os.Getenv),
36 }
37 }
38
39 func platformCPU() string {
40 return parseCPUModel(readOr("/proc/cpuinfo"))
41 }
42
43 func platformRAMBytes() uint64 {
44 return parseMemTotalBytes(readOr("/proc/meminfo"))
45 }
46
46 lines GO