mirror of
https://github.com/golang/go
synced 2024-11-15 06:40:37 -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:
parent
008cc58a11
commit
723d34f171
@ -40,17 +40,15 @@ func osCpuInfoName() string {
|
|||||||
|
|
||||||
scanner := bufio.NewScanner(bytes.NewReader(buf))
|
scanner := bufio.NewScanner(bytes.NewReader(buf))
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
line := scanner.Text()
|
key, value, found := strings.Cut(scanner.Text(), ": ")
|
||||||
if !strings.Contains(line, ":") {
|
if !found {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
switch strings.TrimSpace(key) {
|
||||||
field := strings.SplitN(line, ": ", 2)
|
|
||||||
switch strings.TrimSpace(field[0]) {
|
|
||||||
case "Model Name", "model name":
|
case "Model Name", "model name":
|
||||||
modelName = field[1]
|
modelName = value
|
||||||
case "CPU MHz", "cpu MHz":
|
case "CPU MHz", "cpu MHz":
|
||||||
cpuMHz = field[1]
|
cpuMHz = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user