Linux APIs with idiomatic Go interfaces.
github.com/alexfalkowski/go-linux/v2 provides 26 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.
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.
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 |
| sched | Placing Linux worker threads on selected CPUs and setting CPU policy and block I/O priority | util-linux taskset |
| rlimit | Inspecting and applying process resource limits before a worker starts its workload | util-linux prlimit |
| uring | Queuing positional and vectored I/O and file sync in a storage worker | liburing |
| perf | Counting and sampling CPU time, faults, and hardware events during a bounded workload | Linux perf stat |
| 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 |
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.