tklauser/go-sysconf

sysconf and pathconf for Go, without using cgo

Go

151

420 commits

updated Oct 9, 2026

See the code

README

go-sysconf

Go Reference GitHub Action Status

sysconf and pathconf for Go, without using cgo or external binaries (e.g. getconf).

Supported operating systems: Linux, macOS, DragonflyBSD, FreeBSD, NetBSD, OpenBSD, Solaris/Illumos.

All POSIX.1 and POSIX.2 variables are supported, see References for a complete list.

System-wide variables are available as SC_* constants and are queried using the Sysconf function.

Path-dependent variables are available as PC_* constants and queried using the Pathconf or Fpathconf functions.

Additionally, the following non-standard variables are supported on some operating systems:

VariableSupported on
SC_PHYS_PAGESLinux, macOS, FreeBSD, NetBSD, OpenBSD, Solaris/Illumos
SC_AVPHYS_PAGESLinux, OpenBSD, Solaris/Illumos
SC_NPROCESSORS_CONFLinux, macOS, FreeBSD, NetBSD, OpenBSD, Solaris/Illumos
SC_NPROCESSORS_ONLNLinux, macOS, FreeBSD, NetBSD, OpenBSD, Solaris/Illumos
SC_UIO_MAXIOVLinux

Usage

package main

import (
	"fmt"

	"github.com/tklauser/go-sysconf"
)

func main() {
	// get clock ticks, this will return the same as C.sysconf(C._SC_CLK_TCK)
	clktck, err := sysconf.Sysconf(sysconf.SC_CLK_TCK)
	if err == nil {
		fmt.Printf("SC_CLK_TCK: %v\n", clktck)
	}

	// get the maximum filename length for the root directory
	namemax, err := sysconf.Pathconf("/", sysconf.PC_NAME_MAX)
	if err == nil {
		fmt.Printf("PC_NAME_MAX: %v\n", namemax)
	}
}

References

bsd
cgo
getconf
go
golang
linux
posix
sysconf
sysconfig
system-programming
unix

tklauser/go-sysconf

sysconf and pathconf for Go, without using cgo

Go

151

420 commits

updated Oct 9, 2026

See the code

README

go-sysconf

Go Reference GitHub Action Status

sysconf and pathconf for Go, without using cgo or external binaries (e.g. getconf).

Supported operating systems: Linux, macOS, DragonflyBSD, FreeBSD, NetBSD, OpenBSD, Solaris/Illumos.

All POSIX.1 and POSIX.2 variables are supported, see References for a complete list.

System-wide variables are available as SC_* constants and are queried using the Sysconf function.

Path-dependent variables are available as PC_* constants and queried using the Pathconf or Fpathconf functions.

Additionally, the following non-standard variables are supported on some operating systems:

VariableSupported on
SC_PHYS_PAGESLinux, macOS, FreeBSD, NetBSD, OpenBSD, Solaris/Illumos
SC_AVPHYS_PAGESLinux, OpenBSD, Solaris/Illumos
SC_NPROCESSORS_CONFLinux, macOS, FreeBSD, NetBSD, OpenBSD, Solaris/Illumos
SC_NPROCESSORS_ONLNLinux, macOS, FreeBSD, NetBSD, OpenBSD, Solaris/Illumos
SC_UIO_MAXIOVLinux

Usage

package main

import (
	"fmt"

	"github.com/tklauser/go-sysconf"
)

func main() {
	// get clock ticks, this will return the same as C.sysconf(C._SC_CLK_TCK)
	clktck, err := sysconf.Sysconf(sysconf.SC_CLK_TCK)
	if err == nil {
		fmt.Printf("SC_CLK_TCK: %v\n", clktck)
	}

	// get the maximum filename length for the root directory
	namemax, err := sysconf.Pathconf("/", sysconf.PC_NAME_MAX)
	if err == nil {
		fmt.Printf("PC_NAME_MAX: %v\n", namemax)
	}
}

References

bsd
cgo
getconf
go
golang
linux
posix
sysconf
sysconfig
system-programming
unix

Project health

Overall

4.8/10

Maintained

10/10

Code review

0/10
OpenSSF Scorecard

Latest release

v0.4.0 · May 12, 2026

Releases this year

2

Significant stargazers

Matt Layher

2,098 followers · starred Sep 2018

Seth Hoenig

176 followers · starred Apr 2021

Kirill Shvakov

94 followers · starred Feb 2022

Nikolay

61 followers · starred May 2021