1
0
mirror of https://github.com/golang/go synced 2024-11-18 14:54:40 -07:00

internal/syscall/unix: KernelVersion nitpicks

A few minor improvements for KernelVersion for the sake of readability.

Change-Id: I06d2df60ecee8ee0ae603952470fb73e7dcd5d74
Reviewed-on: https://go-review.googlesource.com/c/go/+/427676
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
This commit is contained in:
Kir Kolyshkin 2022-09-01 14:50:26 -07:00 committed by Tobias Klauser
parent e2e69ec82a
commit 4c1ca42aa2

View File

@ -13,17 +13,17 @@ import (
// or parsed.
//
// Currently only implemented for Linux.
func KernelVersion() (major int, minor int) {
func KernelVersion() (major, minor int) {
var uname syscall.Utsname
if err := syscall.Uname(&uname); err != nil {
return
}
rl := uname.Release
var values [2]int
vi := 0
value := 0
for _, c := range rl {
var (
values [2]int
value, vi int
)
for _, c := range uname.Release {
if '0' <= c && c <= '9' {
value = (value * 10) + int(c-'0')
} else {