gitee.com/ks-custle/core-gm@v0.0.0-20230922171213-b83bdd97b62c/internal/sysinfo/sysinfo.go (about) 1 // Copyright 2020 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Package sysinfo implements high level hardware information gathering 6 // that can be used for debugging or information purposes. 7 package sysinfo 8 9 import ( 10 "sync" 11 12 internalcpu "gitee.com/ks-custle/core-gm/internal/cpu" 13 ) 14 15 type cpuInfo struct { 16 once sync.Once 17 name string 18 } 19 20 var CPU cpuInfo 21 22 func (cpu *cpuInfo) Name() string { 23 cpu.once.Do(func() { 24 // Try to get the information from internal/cpu. 25 if name := internalcpu.Name(); name != "" { 26 cpu.name = name 27 return 28 } 29 // TODO(martisch): use /proc/cpuinfo and /sys/devices/system/cpu/ on Linux as fallback. 30 }) 31 return cpu.name 32 }