daftcreations / go-nproc

OS agnostic nproc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go-nproc

Licence build tag go-report Lines of code Discrod
Downloads

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 nproc

The 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

Usage

$ 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

Install

## 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)

Contributors


Stargazers over time

May the source be with you

About

OS agnostic nproc

License:Apache License 2.0


Languages

Language:Go 100.0%