mirror of
https://github.com/kubenetworks/kubevpn.git
synced 2025-12-24 11:51:13 +08:00
chore: upgrade go mod library
This commit is contained in:
20
vendor/github.com/tklauser/go-sysconf/sysconf_linux.go
generated
vendored
20
vendor/github.com/tklauser/go-sysconf/sysconf_linux.go
generated
vendored
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user