SVI f0f9e02a00 SVI Исправления, обновление вендоринга hai 3 meses
..
.cirrus.yml f0f9e02a00 SVI Исправления, обновление вендоринга hai 3 meses
LICENSE f0f9e02a00 SVI Исправления, обновление вендоринга hai 3 meses
README.md f0f9e02a00 SVI Исправления, обновление вендоринга hai 3 meses
numcpus.go f0f9e02a00 SVI Исправления, обновление вендоринга hai 3 meses
numcpus_bsd.go f0f9e02a00 SVI Исправления, обновление вендоринга hai 3 meses
numcpus_linux.go f0f9e02a00 SVI Исправления, обновление вендоринга hai 3 meses
numcpus_list_unsupported.go f0f9e02a00 SVI Исправления, обновление вендоринга hai 3 meses
numcpus_solaris.go f0f9e02a00 SVI Исправления, обновление вендоринга hai 3 meses
numcpus_unsupported.go f0f9e02a00 SVI Исправления, обновление вендоринга hai 3 meses
numcpus_windows.go f0f9e02a00 SVI Исправления, обновление вендоринга hai 3 meses

README.md

numcpus

Go Reference GitHub Action Status

Package numcpus provides information about the number of CPUs in the system.

It gets the number of CPUs (online, offline, present, possible, configured or kernel maximum) on Linux, Darwin, FreeBSD, NetBSD, OpenBSD, DragonflyBSD or Solaris/Illumos systems.

On Linux, the information is retrieved by reading the corresponding CPU topology files in /sys/devices/system/cpu.

On BSD systems, the information is retrieved using the hw.ncpu and hw.ncpuonline sysctls, if supported.

Not all functions are supported on Darwin, FreeBSD, NetBSD, OpenBSD, DragonflyBSD and Solaris/Illumos. ErrNotSupported is returned in case a function is not supported on a particular platform.

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