Source File
kernel_version_linux.go
Belonging Package
internal/syscall/unix
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package unix
import (
)
// KernelVersion returns major and minor kernel version numbers, parsed from
// the syscall.Uname's Release field, or 0, 0 if the version can't be obtained
// or parsed.
//
// Currently only implemented for Linux.
func () (, int) {
var syscall.Utsname
if := syscall.Uname(&); != nil {
return
}
var (
[2]int
, int
)
for , := range .Release {
if '0' <= && <= '9' {
= ( * 10) + int(-'0')
} else {
// Note that we're assuming N.N.N here.
// If we see anything else, we are likely to mis-parse it.
[] =
++
if >= len() {
break
}
= 0
}
}
return [0], [1]
}
The pages are generated with Golds v0.7.0-preview. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |