linux

package module
v2.21.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 0 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README ¶

Gopher CircleCI codecov Go Reference

go-linux

Linux APIs with idiomatic Go interfaces.

github.com/alexfalkowski/go-linux/v2 provides 22 focused Linux facilities that compose with standard Go interfaces. Use it for kernel features that ordinary file, network, and process APIs do not express. Continue using the standard library for ordinary Go I/O and process creation.

The library targets Linux 7.0+ and the Go version in go.mod. CircleCI requests native arm64 and amd64 runtime verification, including isolated mount tests. The verification guide records runtime evidence and links to known execution limits.

💻 First use

Add the module to a Linux Go application:

go get github.com/alexfalkowski/go-linux/v2

Import the facility you need. For example, create a memory-backed file using ordinary Go I/O:

//go:build linux

package main

import (
    "fmt"
    "os"

    "github.com/alexfalkowski/go-linux/v2/memfd"
)

func main() {
    file, err := memfd.New("hello", memfd.Options{})
    if err != nil {
        panic(err)
    }
    defer file.Close()

    if _, err := file.WriteString("hello, Linux\n"); err != nil {
        panic(err)
    }

    info, err := file.Stat()
    if err != nil {
        panic(err)
    }
    fmt.Fprintln(os.Stdout, info.Size()) // 13
}

See memfd usage for seals and executable examples for shared mappings. The support guide covers feature prerequisites, compatibility, omissions, and dependency licenses.

📦 Packages

Choose a package by what you want to build. The tool links illustrate practical uses of the underlying Linux facilities independently of this module. Each package guide explains the supported operations and prerequisites.

Package Good for Real-world reference
memfd Preparing memory-backed payloads with optional irreversible seals PipeWire media buffers
eventfd Signaling workers or processes through a readiness loop QEMU device notifications
timerfd Scheduling readiness events against an explicit Linux clock systemd event timers
mmap Reading files through memory mappings, sharing mapped regions, and locking mapped buffers in memory SQLite mapped reads
pidfd Observing and signaling a stable process identity and duplicating open worker files systemd child monitoring
process Adopting and reaping orphaned workers as a supervisor or PID namespace init Tini subreaping
mount Preparing and attaching filesystems and inspecting mount trees runc filesystem setup
epoll Waiting for multiple kernel I/O sources in an explicit event loop Redis readiness backend
file Restricting path lookup, querying metadata, renaming atomically, allocating file ranges, setting access advice, synchronizing storage, and locking files or byte ranges GNU mv atomic exchanges
xattr Preserving file metadata in backups and restores GNU tar extended attributes
inotify Watching directories for rebuilds, indexing, or cache invalidation Watchman file watching
fanotify Inspecting accessed files and answering permission requests ClamAV on-access scanning
socket Exchanging Unix messages, open files, and credentials systemd service notifications
netlink Building kernel requests and discovering Generic Netlink families iw wireless configuration
netlink/route Inspecting and configuring interfaces, addresses, multipath routes, nexthop objects, neighbors, and policy rules iproute2 routing commands
namespace Inspecting or entering isolated Linux resource views runc namespaces
cgroup Applying CPU, memory, task, and block I/O limits and placing workloads in a delegated v2 hierarchy systemd resource control
capability Inspecting and reducing Linux thread privileges runc capability policy
seccomp Restricting the syscalls a workload may invoke runc syscall filters
landlock Restricting filesystem access and TCP ports without a privileged helper Landrun sandboxing
procfs Building process monitors and system statistics collectors htop process collection
sysfs Inspecting block devices and network-interface attributes lsblk device discovery

🚀 Setup

Use the Go version declared in go.mod.

Initialize the shared build tooling before using Make targets. Fetching the submodule requires SSH access to GitHub:

git submodule sync && git submodule update --init
make dep
make help

The shared tooling uses betteralign and golangci-lint for linting, gotestsum for tests, and govulncheck and Trivy for security checks. The CI image supplies these tools; install them locally to run the corresponding targets.

For contributions, follow AGENTS.md and the API conventions. The accepted-design index links to package decisions and rationale. Verification guidance owns checks, profiles, reports, and runner requirements.

Documentation ¶

Overview ¶

Package linux is the foundation for Linux APIs with idiomatic Go interfaces.

Directories ¶

Path Synopsis
Package capability inspects and changes the calling Linux thread's capability sets.
Package capability inspects and changes the calling Linux thread's capability sets.
Package cgroup provides owned handles to Linux cgroup v2 directories.
Package cgroup provides owned handles to Linux cgroup v2 directories.
Package epoll provides explicit Linux readiness sets for standard files and typed facility registrations.
Package epoll provides explicit Linux readiness sets for standard files and typed facility registrations.
Package eventfd provides Linux event counters with Go polling and deadlines.
Package eventfd provides Linux event counters with Go polling and deadlines.
Package fanotify provides Linux descriptor-based filesystem notifications and access permission decisions.
Package fanotify provides Linux descriptor-based filesystem notifications and access permission decisions.
Package file provides bounded Linux file extensions while reusing os.File for ownership and ordinary I/O. Prefer os and os.Root for ordinary operations.
Package file provides bounded Linux file extensions while reusing os.File for ownership and ordinary I/O. Prefer os and os.Root for ordinary operations.
Package inotify provides Linux file and directory notifications.
Package inotify provides Linux file and directory notifications.
internal
cmd/testenv command
Command testenv emits Linux verification prerequisites as JSON.
Command testenv emits Linux verification prerequisites as JSON.
mountinfo
Package mountinfo decodes the Linux statmount response buffer.
Package mountinfo decodes the Linux statmount response buffer.
nsfd
Package nsfd shares namespace ownership internals with facilities that borrow namespace references for their own operations.
Package nsfd shares namespace ownership internals with facilities that borrow namespace references for their own operations.
test
Package test provides shared Linux test fixtures and bounded synchronization.
Package test provides shared Linux test fixtures and bounded synchronization.
testenv
Package testenv discovers the Linux prerequisites used by this repository's verification commands.
Package testenv discovers the Linux prerequisites used by this repository's verification commands.
waitstatus
Package waitstatus decodes Linux child exit records for process and pidfd.
Package waitstatus decodes Linux child exit records for process and pidfd.
Package landlock builds Linux access rulesets and explicitly applies them to the calling thread or all threads of the calling process.
Package landlock builds Linux access rulesets and explicitly applies them to the calling thread or all threads of the calling process.
Package memfd creates Linux memory-backed files with irreversible file seals.
Package memfd creates Linux memory-backed files with irreversible file seals.
Package mmap owns Linux anonymous and file-backed memory mappings.
Package mmap owns Linux anonymous and file-backed memory mappings.
Package mount provides filesystem configuration, mount operations, and structured mount discovery on Linux 7.0+.
Package mount provides filesystem configuration, mount operations, and structured mount discovery on Linux 7.0+.
Package namespace owns Linux namespace handles and exposes explicit setns and unshare operations.
Package namespace owns Linux namespace handles and exposes explicit setns and unshare operations.
Package netlink implements Linux Netlink framing, kernel requests, dumps, acknowledgements, and multicast reception over the socket package.
Package netlink implements Linux Netlink framing, kernel requests, dumps, acknowledgements, and multicast reception over the socket package.
route
Package route provides typed Linux rtnetlink operations for links, IPv4/IPv6 addresses, routes, nexthop objects, neighbors, and policy rules.
Package route provides typed Linux rtnetlink operations for links, IPv4/IPv6 addresses, routes, nexthop objects, neighbors, and policy rules.
Package pidfd owns Linux process descriptors for signaling, exit observation, eligible child reaping, and file duplication.
Package pidfd owns Linux process descriptors for signaling, exit observation, eligible child reaping, and file duplication.
Package process provides Linux child-subreaper controls and wait-any reaping for a dedicated worker supervisor or PID namespace init.
Package process provides Linux child-subreaper controls and wait-any reaping for a dedicated worker supervisor or PID namespace init.
Package procfs provides bounded, read-only process and system information through a project-owned API backed by github.com/prometheus/procfs.
Package procfs provides bounded, read-only process and system information through a project-owned API backed by github.com/prometheus/procfs.
Package seccomp loads bounded classic-BPF Linux syscall filters.
Package seccomp loads bounded classic-BPF Linux syscall filters.
Package socket provides Linux message sockets, ancillary file/credential handling, and selected Netlink options.
Package socket provides Linux message sockets, ancillary file/credential handling, and selected Netlink options.
Package sysfs provides bounded, read-only block-device and network-interface information with an explicit sysfs or fixture root.
Package sysfs provides bounded, read-only block-device and network-interface information with an explicit sysfs or fixture root.
Package timerfd provides Linux descriptor timers with expiration counts, Go polling, and read deadlines.
Package timerfd provides Linux descriptor timers with expiration counts, Go polling, and read deadlines.
Package xattr reads and modifies Linux extended attributes on standard files and directory-relative paths using the Linux 7.0 baseline at-style calls.
Package xattr reads and modifies Linux extended attributes on standard files and directory-relative paths using the Linux 7.0 baseline at-style calls.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL