Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Get ¶
Get returns the value of key as string.
Example ¶
Get will return the OS release version. On linux the kernel version something like: 6.13.3 On OpenBSD something like: 7.6
package main
import (
"fmt"
"runtime"
"catinello.eu/sysctl"
)
func main() {
var key string
switch runtime.GOOS {
case "linux":
key = "kernel.osrelease"
case "openbsd", "freebsd", "netbsd", "dragonfly", "darwin":
key = "kern.osrelease"
}
version, err := sysctl.Get(key)
if err != nil {
panic(err)
}
fmt.Println(version)
}
func List ¶
List returns a slice of strings of all available keys.
Example ¶
List will return a list of available sysctl keys. We will filter by "kern" prefix.
package main
import (
"fmt"
"strings"
"catinello.eu/sysctl"
)
func main() {
list, err := sysctl.List()
if err != nil {
panic(err)
}
for _, l := range list {
if strings.HasPrefix(l, "kern") {
fmt.Println(l)
}
}
}
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.