$21 GRAYBYTE WORDPRESS FILE MANAGER $47

SERVER : vnpttt-amd7f72-h1.vietnix.vn #1 SMP Fri May 24 12:42:50 UTC 2024
SERVER IP : 103.200.23.149 | ADMIN IP 216.73.216.22
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/usr/lib/golang/src/internal/sysinfo/

HOME
Current File : /usr/lib/golang/src/internal/sysinfo//cpuinfo_linux.go
// 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

import (
	"bufio"
	"bytes"
	"io"
	"os"
	"strings"
)

func readLinuxProcCPUInfo(buf []byte) error {
	f, err := os.Open("/proc/cpuinfo")
	if err != nil {
		return err
	}
	defer f.Close()

	_, err = io.ReadFull(f, buf)
	if err != nil && err != io.ErrUnexpectedEOF {
		return err
	}

	return nil
}

func osCPUInfoName() string {
	modelName := ""
	cpuMHz := ""

	// The 512-byte buffer is enough to hold the contents of CPU0
	buf := make([]byte, 512)
	err := readLinuxProcCPUInfo(buf)
	if err != nil {
		return ""
	}

	scanner := bufio.NewScanner(bytes.NewReader(buf))
	for scanner.Scan() {
		key, value, found := strings.Cut(scanner.Text(), ": ")
		if !found {
			continue
		}
		switch strings.TrimSpace(key) {
		case "Model Name", "model name":
			modelName = value
		case "CPU MHz", "cpu MHz":
			cpuMHz = value
		}
	}

	if modelName == "" {
		return ""
	}

	if cpuMHz == "" {
		return modelName
	}

	// 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
	f := [...]string{"GHz", "MHz"}
	for _, v := range f {
		if strings.Contains(modelName, v) {
			return modelName
		}
	}

	return modelName + " @ " + cpuMHz + "MHz"
}

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
16 Dec 2025 9.30 PM
root / root
0755
cpuinfo_bsd.go
0.336 KB
4 Dec 2025 6.06 PM
root / root
0644
cpuinfo_linux.go
1.4 KB
4 Dec 2025 6.06 PM
root / root
0644
cpuinfo_stub.go
0.276 KB
4 Dec 2025 6.06 PM
root / root
0644
sysinfo.go
0.506 KB
4 Dec 2025 6.06 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF