Source file src/internal/sysinfo/sysinfo.go
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 internalcpu "internal/cpu" 11 "sync" 12 ) 13 14 type cpuInfo struct { 15 once sync.Once 16 name string 17 } 18 19 var CPU cpuInfo 20 21 func (cpu *cpuInfo) Name() string { 22 cpu.once.Do(func() { 23 // Try to get the information from internal/cpu. 24 if name := internalcpu.Name(); name != "" { 25 cpu.name = name 26 return 27 } 28 // TODO(martisch): use /proc/cpuinfo and /sys/devices/system/cpu/ on Linux as fallback. 29 }) 30 return cpu.name 31 } 32