/
View dependency graph
Depends on
- dh-golang (dh-golang)
- golang-defaults (golang-any)
- golang-golang-x-sys (golang-golang-x-sys-dev)
- debhelper-compat
README (full)
numcpus
Package numcpus provides information about the number of CPU in a system.
It gets the number of CPUs (online, offline, present, possible, configured or kernel maximum) on a Linux, Darwin, FreeBSD, NetBSD, OpenBSD, DragonflyBSD or Solaris/Illumos system.
On Linux, the information is retrieved by reading the corresponding CPU
topology files in /sys/devices/system/cpu.
Not all functions are supported on Darwin, FreeBSD, NetBSD, OpenBSD, DragonflyBSD and Solaris/Illumos.
Usage
package main
import (
"fmt"
"os"
"github.com/tklauser/numcpus"
)
func main() {
online, err := numcpus.GetOnline()
if err != nil {
fmt.Fprintf(os.Stderr, "GetOnline: %v\n", err)
}
fmt.Printf("online CPUs: %v\n", online)
possible, err := numcpus.GetPossible()
if err != nil {
fmt.Fprintf(os.Stderr, "GetPossible: %v\n", err)
}
fmt.Printf("possible CPUs: %v\n", possible)
}
References
| dir | .github/ |
| dir | cmd/ |
| dir | debian/ |
| file | .cirrus.yml |
| file | LICENSE |
| file | README.md |
| file | example_test.go |
| file | go.mod |
| file | go.sum |
| file | numcpus.go |
| file | numcpus_bsd.go |
| file | numcpus_linux.go |
| file | numcpus_linux_test.go |
| file | numcpus_solaris.go |
| file | numcpus_test.go |
| file | numcpus_unsupported.go |