Standard library
API reference
Complete index of 224 public exports across 41 standard-library modules.
How to read this index
Each row is a public export from a std/ module. Import the module, then call module.export(...). Open the module page for the package outline (constants, structs, methods, functions). Private test helpers are not included.
Core
Modules: I/O (/docs/std/io); Strings (/docs/std/str); Bytes (/docs/std/bytes); Lists (/docs/std/list); Time (/docs/std/time); Math (/docs/std/math); Buffered lines (/docs/std/bufio); Testing (/docs/std/test); Reflection (/docs/std/reflect).
; std/io → /docs/std/io
/ std/io
io.print(value): Write a string to standard output with a newline
io.log(value): Write a string to the log stream with a newline
io.eprint(value): Write a string to standard error with a newline
; std/str → /docs/std/str
/ std/str
str.from_int(n): Integer to decimal string
str.from_float(n): Float to string
str.from_bytes(b): UTF-8 decode bytes to string (lossy)
str.from_duration(d): Duration to human unit string
str.from_locator(loc): Locator path or URI to string
str.from_debug(v): Shallow debug text for any value
str.len(s): Length in UTF-8 bytes
str.is_empty(s): True when the string is empty
str.cat(a, b): Concatenate two strings
str.contains(hay, needle): True when hay contains needle
str.starts_with(s, prefix): True when string starts with prefix
str.ends_with(s, suffix): True when string ends with suffix
str.get(s, i): UTF-8 byte at index (result-shaped)
str.slice(s, start, end): UTF-8 byte slice [start, end) (result-shaped)
str.trim(s): Strip leading and trailing ASCII whitespace
str.to_lower(s): ASCII lowercase
str.to_upper(s): ASCII uppercase
str.split(s, sep): Split on separator into a list of strings
str.replace(s, from, to): Replace all occurrences of a substring
str.join(parts, sep): Join list of strings with a separator
str.repeat(s, n): Repeat a string n times
str.parse_int(s): Parse an integer; error on failure
str.parse_float(s): Parse a float; error on failure
; std/bytes → /docs/std/bytes
/ std/bytes
bytes.len(b): Length in bytes
bytes.is_empty(b): True when empty
bytes.get(b, i): Bounds-checked byte access (result-shaped)
bytes.slice(b, start, end): Half-open range extract (result-shaped)
bytes.cat(a, b): Concatenate two byte sequences
bytes.from_int(n): Pack integer as 8 little-endian bytes
bytes.from_str(s): UTF-8 encode a string to bytes
; std/list → /docs/std/list
/ std/list
list.len(xs): Element count
list.is_empty(xs): True when the list is empty
list.get(xs, i): Bounds-checked element access (result-shaped)
list.contains(xs, x): True when the list contains the value
list.sum_ints(xs): Sum of integer elements
list.sort_ints(xs): Sort integers ascending
; std/time → /docs/std/time
/ std/time
time.now_ms(): Unix epoch milliseconds (UTC wall clock)
time.sleep_ms(ms): Sleep at least ms milliseconds
time.mono_ms(): Monotonic milliseconds since process start
time.format(ms, fmt): Format wall-ms with a strftime-like pattern
time.parse(s, fmt): Parse text with a pattern to wall-ms
; std/math → /docs/std/math
/ std/math
math.abs_i(n): Absolute value of an integer
math.min(a, b): Minimum of two integers
math.max(a, b): Maximum of two integers
math.sqrt(x): Square root
math.sin(x): Sine
math.cos(x): Cosine
math.tan(x): Tangent
math.floor(x): Floor
math.ceil(x): Ceiling
math.abs_f(x): Absolute value of a float
math.pow(a, b): Power
; std/bufio → /docs/std/bufio
/ std/bufio
bufio.lines(s): Split text into lines on newline
bufio.read_lines(path): Read a file and split into lines
; std/test → /docs/std/test
/ std/test
test.it(name, body): Register a test case
test.eq(left, right): Assert deep equality
test.ne(left, right): Assert inequality
test.true(cond): Assert truthy
test.false(cond): Assert falsey
test.fail(msg): Fail the current test with a message
; std/reflect → /docs/std/reflect
/ std/reflect
reflect.kind(v): Runtime kind tag for a value
reflect.kind_name(v): Human-readable kind name
reflect.key_bytes(v): Stable key bytes for map and set hashing
reflect.is_int(v): True when the value kind is int
reflect.is_string(v): True when the value kind is string
reflect.is_bytes(v): True when the value kind is bytes
reflect.is_list(v): True when the value kind is list
reflect.is_float(v): True when the value kind is float
reflect.is_struct(v): True when the value kind is struct
reflect.KIND_INT: Kind tag constant for int values
reflect.KIND_LIST: Kind tag constant for list values
reflect.KIND_STRING: Kind tag constant for string values
reflect.KIND_STRUCT: Kind tag constant for struct values
reflect.KIND_FLOAT: Kind tag constant for float values
reflect.KIND_BYTES: Kind tag constant for bytes values
Files and process
Modules: Path (/docs/std/path); Filesystem (/docs/std/fs); Process (/docs/std/process); OS (/docs/std/os).
; std/path → /docs/std/path
/ std/path
path.join(base, rel): Join path segments with platform rules
path.is_abs(p): True for absolute paths
path.file_name(p): Final path component
path.parent(p): Parent directory path
path.extension(p): File extension without the dot
path.clean(p): Clean . and .. path segments
path.rel(base, target): Relative path from base to target
path.walk(root): List direct children under a directory
; std/fs → /docs/std/fs
/ std/fs
fs.exists(path): True if the path exists
fs.is_file(path): True if the path is a regular file
fs.is_dir(path): True if the path is a directory
fs.join(base, rel): Join path segments with platform rules
fs.read(path): Read a whole file as bytes
fs.write(path, data): Write a whole file
fs.remove(path): Remove a file
fs.copy(from, to): Copy a file
fs.rename(from, to): Rename or move a path
fs.create_dir(path): Create a directory
fs.create_dir_all(path): Create a directory tree
fs.read_dir(path): List directory entry names
fs.remove_dir(path): Remove an empty directory
fs.metadata(path): File metadata product
fs.open(path): Open a file for reading
fs.create(path): Create or truncate a file for writing
fs.append(path): Open a file for append
fs.meta: Metadata product shape
fs.file: Streaming file handle shape
fs.temp_dir(): System temporary directory path
fs.create_temp(prefix): Create a temporary path
fs.symlink(original, link): Create a symbolic link
fs.chmod(path, mode): Set Unix file mode bits
; std/process → /docs/std/process
/ std/process
process.args(): Process argv as a list of strings
process.env(name): Look up an environment variable (option)
process.env_set(name, value): Set an environment variable
process.env_unset(name): Unset an environment variable
process.exit(code): Terminate with an exit code
process.run(program, args): Spawn and wait for an exit code
process.run_capture(program, args): Spawn and capture stdout and stderr
process.run_cwd(program, args, cwd): Spawn with a working directory; capture output
process.spawn_pipes(program, args): Spawn with piped stdin, stdout, and stderr handles
process.pipe_write(pipe, data): Write to a process pipe (stdin)
process.pipe_read(pipe, limit): Read from a process pipe (stdout or stderr)
process.pipe_close(pipe): Close one end of a process pipe
process.wait(child): Wait for a child process; returns exit code
; std/os → /docs/std/os
/ std/os
os.pid(): Current process id
os.cwd(): Current working directory
os.chdir(path): Change working directory
os.hostname(): Host name string
os.platform(): OS platform string
Data
Modules: JSON (/docs/std/json); Hex (/docs/std/encoding-hex); Base64 (/docs/std/encoding-base64); CSV (/docs/std/encoding-csv); gzip (/docs/std/compress-gzip); zip (/docs/std/compress-zip).
; std/json → /docs/std/json
/ std/json
json.parse(s): Parse JSON text to a product value
json.stringify(v): Serialize a product value to JSON text
; std/encoding/hex → /docs/std/encoding-hex
/ std/encoding/hex
hex.encode(b): Encode bytes or text to a hex string
hex.decode(s): Decode a hex string to bytes
; std/encoding/base64 → /docs/std/encoding-base64
/ std/encoding/base64
base64.encode(b): Encode bytes or text to a base64 string
base64.decode(s): Decode a base64 string to bytes
; std/encoding/csv → /docs/std/encoding-csv
/ std/encoding/csv
csv.parse_line(s): Split one CSV line into fields
csv.parse(s): Parse multi-line CSV into rows
csv.format_line(fields): Join fields into a CSV line
; std/compress/gzip → /docs/std/compress-gzip
/ std/compress/gzip
gzip.compress(data): Compress input to gzip bytes
gzip.decompress(data): Decompress gzip bytes
; std/compress/zip → /docs/std/compress-zip
/ std/compress/zip
zip.pack(name, data): Pack a single named entry into a zip
zip.unpack_first(data): Unpack the first zip entry
Collections
Modules: Map (/docs/std/collections-map); Set (/docs/std/collections-set); Queue (/docs/std/collections-queue); Hash table (/docs/std/collections-hash_table).
; std/collections/map → /docs/std/collections-map
/ std/collections/map
map.map: Map shape with put and get methods
map.make(): Construct an empty map
map.from_indexed(ls): Build a map from indexed pairs
; std/collections/set → /docs/std/collections-set
/ std/collections/set
set.set: Set shape with add and has methods
set.make(): Construct an empty set
set.from_list(ls): Build a set from a list
; std/collections/queue → /docs/std/collections-queue
/ std/collections/queue
queue.queue: FIFO queue shape
queue.make(): Construct an empty queue
; std/collections/hash_table → /docs/std/collections-hash_table
/ std/collections/hash_table
hash_table.hash_table: Hash table shape
hash_table.make(): Construct an empty hash table
Crypto and random
Modules: Hash (/docs/std/crypto-hash); HMAC (/docs/std/crypto-hmac); AES-GCM (/docs/std/crypto-aes_gcm); CSPRNG (/docs/std/crypto-random); PRNG (/docs/std/random); Logging (/docs/std/log).
; std/crypto/hash → /docs/std/crypto-hash
/ std/crypto/hash
hash.sha256(data): SHA-256 digest (32 bytes)
hash.sha512(data): SHA-512 digest (64 bytes)
hash.sip(k0, k1, msg): SipHash-2-4 of a message with k0 and k1 keys
; std/crypto/hmac → /docs/std/crypto-hmac
/ std/crypto/hmac
hmac.sha256(key, data): HMAC-SHA256 of key and data (32 bytes)
; std/crypto/aes_gcm → /docs/std/crypto-aes_gcm
/ std/crypto/aes_gcm
aes_gcm.encrypt(key, nonce, plaintext): AES-256-GCM encrypt (32-byte key, 12-byte nonce)
aes_gcm.decrypt(key, nonce, ciphertext): AES-256-GCM decrypt
; std/crypto/random → /docs/std/crypto-random
/ std/crypto/random
random.fill(n): Fill n bytes from the CSPRNG
random.u64(): Cryptographic random u64
; std/random → /docs/std/random
/ std/random
random.seed(s): Seed the non-crypto PRNG
random.u64(): Next PRNG u64
random.float(): Next PRNG float in [0, 1)
; std/log → /docs/std/log
/ std/log
log.emit(min_level, msg_level, prefix, msg): Emit a message when msg_level meets min_level
log.debug(min_level, msg): Emit a debug-level message
log.info(min_level, msg): Emit an info-level message
log.warn(min_level, msg): Emit a warning-level message
log.error(min_level, msg): Emit an error-level message
log.kv(pairs): Join key=value pairs into a string
log.info_kv(min_level, msg, pairs): Info line with key=value pairs
Network
Modules: TCP (/docs/std/net-tcp); UDP (/docs/std/net-udp); Unix sockets (/docs/std/net-unix); TLS (/docs/std/net-tls); DNS (/docs/std/net-dns); URL (/docs/std/net-url); HTTP server (/docs/std/net-http); HTTP client (/docs/std/net-http_client); HTTP request (/docs/std/net-request); HTTP response (/docs/std/net-response); HTTP server type (/docs/std/net-server).
; std/net/tcp → /docs/std/net-tcp
/ std/net/tcp
tcp.conn: TCP connection shape
tcp.listener: TCP listener shape
tcp.listen(addr): Start listening; failure yields handle 0
tcp.connect(addr): Connect; failure yields handle 0 or a result error
tcp.accept(lis): Accept a connection; failure yields handle 0
tcp.read(c, limit): Read up to limit bytes
tcp.write(c, data): Write bytes or string data
tcp.close(x): Close the resource
; std/net/udp → /docs/std/net-udp
/ std/net/udp
udp.bind(addr): Bind a UDP socket
udp.send_to(sock, data, addr): Send a datagram to an address
udp.recv_from(sock, limit): Receive a datagram with sender address
udp.close(sock): Close the resource
udp.socket: UDP socket shape
; std/net/unix → /docs/std/net-unix
/ std/net/unix
unix.listener: Unix domain listener shape
unix.conn: Unix stream connection shape
unix.listen(path): Start listening; failure yields handle 0
unix.accept(lis): Accept a connection; failure yields handle 0
unix.connect(path): Connect; failure yields handle 0 or a result error
unix.read(c, limit): Read up to limit bytes
unix.write(c, data): Write bytes or string data
unix.close(c): Close the resource
; std/net/tls → /docs/std/net-tls
/ std/net/tls
tls.listener: TLS listener shape
tls.conn: TLS connection shape
tls.listen(addr): Start listening; failure yields handle 0
tls.accept(lis, cert_pem, key_pem): Accept a connection; failure yields handle 0
tls.connect(host, port, server_name, ca_pem): Connect; failure yields handle 0 or a result error
tls.read(c, limit): Read up to limit bytes
tls.write(c, data): Write bytes or string data
tls.close(c): Close the resource
tls.close_listener(lis): Close a TLS listener
tls.load_pem(path): Load a PEM file as a string
; std/net/dns → /docs/std/net-dns
/ std/net/dns
dns.lookup(host): Resolve a host name to address strings
; std/net/url → /docs/std/net-url
/ std/net/url
url.parse(s): Parse an http(s) URL into product fields
url.format(scheme, host, port, path): Build a URL string from scheme, host, port, and path
; std/net/http → /docs/std/net-http
/ std/net/http
http.request: HTTP request shape (re-export)
http.response: HTTP response shape (re-export)
http.server: HTTP server shape (re-export)
http.text_response(status, body): Build a text/plain response
http.html_response(status, body): Build a text/html response
http.json_response(status, body): Build an application/json response
http.parse_request(raw): Parse raw HTTP request bytes
http.format_response(res): Format a response as HTTP bytes
http.dispatch(routes, req): Dispatch a request to matching routes
http.handle_connection(c, routes): Handle one HTTP connection
http.serve(addr, routes): Accept loop serving routes
; std/net/http_client → /docs/std/net-http_client
/ std/net/http_client
http_client.get(host, port, path): HTTP GET over cleartext TCP
http_client.request(method, host, port, path, headers, body): HTTP request with method, headers, and body
http_client.get_tls(host, port, path, server_name, ca_pem): HTTPS GET over TLS
http_client.request_tls(method, host, port, path, headers, body, server_name, ca_pem): HTTPS request over TLS
; std/net/request → /docs/std/net-request
/ std/net/request
request.request: HTTP request shape and helpers
; std/net/response → /docs/std/net-response
/ std/net/response
response.response: HTTP response shape and helpers
; std/net/server → /docs/std/net-server
/ std/net/server
server.server: HTTP server shape
CLI
Modules: CLI flags (/docs/std/cli).
; std/cli → /docs/std/cli
/ std/cli
cli.parse(argv): Parse argv into flags and positionals
cli.has(tokens, name): True if a flag is present
cli.get(tokens, name): Get a flag value
cli.positionals(tokens): Positional arguments list