OS agnostic nproc (gnu nproc in go)
size < 400KB
Motivation: Trying macos first time and I can't find
nproc
utility which will gives you no of logical processor on your system so created one. Tried to create it as similar as GNU nprocThe minimal difference is, this will use single dash
-
for cli flags instead of--
which GNU uses. I wanted to use standard flags library to keep application simple
$ go-nproc -help
go-nproc Usage
-all
print the number of installed processors (default true)
-help
display this help and exit
-ignore int
if possible, exclude N processing units
-version
Get current version
gnu nproc
$ nproc --help Usage: nproc [OPTION]... Print the number of processing units available to the current process, which may be less than the number of online processors --all print the number of installed processors --ignore=N if possible, exclude N processing units --help display this help and exit --version output version information and exit
## Linux
curl -fsSL instl.sh/daftcreations/go-nproc/linux | bash
## MacOS (m1 and intel)
curl -fsSL instl.sh/daftcreations/go-nproc/macos | bash
## Windows
iwr -useb instl.sh/daftcreations/go-nproc/windows | iex
or
go install github.com/daftcreations/go-nproc@latest
Supported platforms, Find binary from release page
- Darwin(Mac) (
arm64
,x86_64
) - tested - Linux (
arm64
,armv6
,armv7
,i386
,x86_64
) tested - OpenBSD (
arm64
,arm6
,armv7
,i386
,x86_64
) - FreeBSD (
arm64
,arm6
,armv7
,i386
,x86_64
) tested - Windows (
armv6
,armv7
,i386
,x86_64
) - Solaris (
x86_64
)
May the source be with you