Skip to content
Node: os.cpus().lengthgithub.com/sahilkhaire/gox/osutil

CPUs

Overview

CPUs returns the number of logical CPUs.

If you are coming from Node.js, the closest pattern is os.cpus().length.

Signature

go
func CPUs() int

Compare: Node.js · Standard Go · gox

js
os.cpus().length
go
// Use the underlying stdlib or driver directly.
// See package overview for escape hatches.
go
import "github.com/sahilkhaire/gox/osutil"

osutil.CPUs()

Example

go
import "github.com/sahilkhaire/gox/osutil"

osutil.CPUs()

Tips

Import github.com/sahilkhaire/gox/osutil and call CPUs directly. See the comparison below for the standard library equivalent.

Standard library alternative

gox wraps the Go standard library or a trusted dependency with Node-familiar naming. You can use the underlying library directly — see the package overview for escape hatches.

Back to osutil package overview

MIT Licensed · Built for Node.js developers moving to Go