On this page
The standard library is source-distributed with the toolchain. Packages compile with the application, while operations that require the operating system, network, clock, process, or browser are provided through governed runtime and host contracts.
Core packages#
errors,fmt,strconv, andstringscover errors, formatting, conversions, and text.bytes,unicode, andunicode/utf8cover byte and Unicode processing.cmp,maps,slices, andsortprovide common collection operations.math,math/bits, andmath/randprovide numerical helpers.regexpprovides regular-expression compilation and matching.
Encoding#
encoding/jsonencodes and decodes typed values and open dynamic values.encoding/tomlhandles TOML configuration data.encoding/base64,encoding/hex, andencoding/binarycover binary interchange.encoding/csvreads and writes row-oriented text data.
Prefer typed structs for stable schemas. Use any and the dyn package when a
schema is intentionally open.
I/O, files, and processes#
io,io/fs,bufio, andbytesdefine stream, filesystem, buffering, and in-memory byte contracts.os,path, andpath/filepathexpose host filesystem and path behavior.os/execstarts governed child processes on hosts that grant the capability.flagparses command-line flags.logsupplies structured application logging primitives.
Host-dependent functions can report unsupported capability on sandboxed targets. Libraries should accept interfaces such as readers, writers, and filesystems so callers can provide deterministic test implementations.
Network and URLs#
netdefines addresses and connection-level contracts.net/httpsupplies HTTP request, response, client, and server behavior where the host supports it.net/urlparses and constructs URLs.
Browser networking remains subject to origin and host policy. Desktop and embedded hosts should grant the narrowest authority needed by the application.
Time, context, and synchronization#
timeprovides instants, durations, timers, and formatting.contextcarries cancellation, deadlines, and request-scoped values.syncprovides synchronization primitives for supported shared-runtime scenarios.- Channels remain the preferred coordination primitive between goroutines in one island. Ports carry messages across islands.
Runtime packages#
runtimeexposes scheduler and runtime information intended for application use.runtime/memexposes bounded memory observations and controls where the backend contract permits them.toolchainexposes versioned toolchain facts to governed generators and build integrations.dyndefines the dynamic-access protocol and stable error categories.
Portability#
Package presence alone does not grant a platform effect. The same API can be implemented by a native provider, a Web host import, a deterministic test provider, or an unsupported-capability response. Check errors and declare UI platform requirements in the application manifest.
The maintained package source lives under lang/stdlib. Its tests in
tests/lang are the executable compatibility contract across VM, JIT, GC
stress, Native AOT, and Wasm VM lanes.