1
0
mirror of https://github.com/golang/go synced 2024-11-15 04:30:32 -07:00

internal/sysinfo: use strings.Cut in osCpuInfoName

Change-Id: I78a6189f0fc5d52b5f88cc0db0d3dbc36f94f826
Reviewed-on: https://go-review.googlesource.com/c/go/+/583715
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Tobias Klauser 2024-05-07 11:05:08 +02:00 committed by Gopher Robot
parent 008cc58a11
commit 723d34f171

View File

@ -40,17 +40,15 @@ func osCpuInfoName() string {
scanner := bufio.NewScanner(bytes.NewReader(buf))
for scanner.Scan() {
line := scanner.Text()
if !strings.Contains(line, ":") {
key, value, found := strings.Cut(scanner.Text(), ": ")
if !found {
continue
}
field := strings.SplitN(line, ": ", 2)
switch strings.TrimSpace(field[0]) {
switch strings.TrimSpace(key) {
case "Model Name", "model name":
modelName = field[1]
modelName = value
case "CPU MHz", "cpu MHz":
cpuMHz = field[1]
cpuMHz = value
}
}