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>
--- /dev/null
+// 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
+}
// 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
--- /dev/null
+// 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
--- /dev/null
+// 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())
+}