Skip to content

oscompat

Cross-platform operating-system compatibility utilities for Go. It holds the code that differs between Windows and Unix-like systems (Linux, macOS), so that other modules do not carry platform-specific files of their own.

go get github.com/grokify/oscompat

Packages

Package Solves Guide
fs Permissions, paths, executables, file locks, durable renames fs
process Signals, process groups, liveness, start time, exec process
paths Config, data, cache and runtime directories paths
id Unique identifiers that do not collide on Windows id
tsync Timestamp comparison across filesystems tsync
localnet Local inter-process sockets localnet
testutil Test helpers that behave the same everywhere testutil

New here? Read Getting started. Writing tests that fail only on Windows? Read Writing tests that pass on Windows.

Policy

oscompat has no dependencies. It imports the Go standard library and itself, and nothing else: no module outside the standard library, and not even golang.org/x/sys. A test in the module enforces it. That is what makes it safe for any module to import, including modules that keep their own dependency set small on purpose, such as ones that handle key material.

In return, modules are encouraged to import oscompat instead of keeping _windows.go and _unix.go files, build tags or runtime.GOOS checks of their own. Code that differs by operating system belongs here once, tested on every platform, so that callers read as portable code.

If a module needs a difference oscompat does not cover, add it here rather than beside the caller, using only the standard library.

Platform support

All packages are tested on Linux, macOS and Windows.

Releases

See the release notes and the changelog.