// 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 sysinfoimport ()func readLinuxProcCPUInfo( []byte) error { , := os.Open("/proc/cpuinfo")if != nil {return }defer .Close() _, = io.ReadFull(, )if != nil && != io.ErrUnexpectedEOF {return }returnnil}func osCPUInfoName() string { := "" := ""// The 512-byte buffer is enough to hold the contents of CPU0 := make([]byte, 512) := readLinuxProcCPUInfo()if != nil {return"" } := bufio.NewScanner(bytes.NewReader())for .Scan() { , , := strings.Cut(.Text(), ": ")if ! {continue }switchstrings.TrimSpace() {case"Model Name", "model name": = case"CPU MHz", "cpu MHz": = } }if == "" {return"" }if == "" {return }// The modelName field already contains the frequency information, // so the cpuMHz field information is not needed. // modelName filed example: // Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz := [...]string{"GHz", "MHz"}for , := range {ifstrings.Contains(, ) {return } }return + " @ " + + "MHz"}
The pages are generated with Goldsv0.7.3-preview. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.