mirror of
https://github.com/golang/go
synced 2024-11-15 00:30:31 -07:00
internal/sysinfo: implement CPUName on bsd systems
sysctl machdep.cpu.brand_string seems to be standard across the BSDs. There does not seem to be a standard way to get the CPU frequency. Change-Id: Ic986d6c81dd54e1b84544317f2a53ce16801319b Reviewed-on: https://go-review.googlesource.com/c/go/+/520636 Auto-Submit: Russ Cox <rsc@golang.org> TryBot-Bypass: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
parent
2e1003e2f7
commit
ed9aed1c9d
14
src/internal/sysinfo/cpuinfo_bsd.go
Normal file
14
src/internal/sysinfo/cpuinfo_bsd.go
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright 2023 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build darwin || freebsd || netbsd || openbsd
|
||||
|
||||
package sysinfo
|
||||
|
||||
import "syscall"
|
||||
|
||||
func osCpuInfoName() string {
|
||||
cpu, _ := syscall.Sysctl("machdep.cpu.brand_string")
|
||||
return cpu
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !linux
|
||||
//go:build !(darwin || freebsd || linux || netbsd || openbsd)
|
||||
|
||||
package sysinfo
|
||||
|
||||
|
7
src/internal/sysinfo/export_test.go
Normal file
7
src/internal/sysinfo/export_test.go
Normal file
@ -0,0 +1,7 @@
|
||||
// Copyright 2023 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package sysinfo
|
||||
|
||||
var XosCpuInfoName = osCpuInfoName
|
15
src/internal/sysinfo/sysinfo_test.go
Normal file
15
src/internal/sysinfo/sysinfo_test.go
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright 2023 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package sysinfo_test
|
||||
|
||||
import (
|
||||
. "internal/sysinfo"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCPUName(t *testing.T) {
|
||||
t.Logf("CPUName: %s", CPUName())
|
||||
t.Logf("osCpuInfoName: %s", XosCpuInfoName())
|
||||
}
|
Loading…
Reference in New Issue
Block a user