chore: upgrade go mod library

This commit is contained in:
fengcaiwen
2025-02-08 20:45:20 +08:00
parent a6730613e7
commit 2fc0bb3f0c
1704 changed files with 163038 additions and 69629 deletions

View File

@@ -6,7 +6,6 @@ package sysconf
import (
"bufio"
"io/ioutil"
"os"
"runtime"
"strconv"
@@ -26,7 +25,7 @@ const (
)
func readProcFsInt64(path string, fallback int64) int64 {
data, err := ioutil.ReadFile(path)
data, err := os.ReadFile(path)
if err != nil {
return fallback
}
@@ -86,10 +85,16 @@ func getNprocsProcStat() (int64, error) {
s := bufio.NewScanner(f)
for s.Scan() {
if line := strings.TrimSpace(s.Text()); strings.HasPrefix(line, "cpu") {
l := strings.SplitN(line, " ", 2)
_, err := strconv.ParseInt(l[0][3:], 10, 64)
if err == nil {
count++
cpu, _, found := strings.Cut(line, " ")
if found {
// skip first line with accumulated values
if cpu == "cpu" {
continue
}
_, err := strconv.ParseInt(cpu[len("cpu"):], 10, 64)
if err == nil {
count++
}
}
} else {
// The current format of /proc/stat has all the
@@ -98,6 +103,9 @@ func getNprocsProcStat() (int64, error) {
break
}
}
if err := s.Err(); err != nil {
return -1, err
}
return count, nil
}