For the complete documentation index, see llms.txt. This page is also available as Markdown.

Overview

OSL keeps the core language small and ships capabilities as a standard library of packages. You pull in what you need with import:

import "osl/fs"

log fs.readFile("notes.txt")

Each package exposes a single global value named after the package (fs, crypto, serve, …) whose methods you call. The osl/ prefix is optional for standard-library packages - import "fs" and import "osl/fs" are equivalent.

How imports work

Form
Meaning

import "osl/fs" / import "fs"

A standard-library package (listed below).

import "./helpers.osl"

Another OSL file in your project (path relative to the current file).

import "go/net/http"

A raw Go package, for advanced interop.

Missing third-party Go dependencies are fetched automatically when you compile.

Returned objects

Some packages give you an object to keep working with. For example, db.open() returns a database handle, and you call further methods on that:

import "osl/db"

*db.DB handle = db.open("app.db")
handle.exec("CREATE TABLE users (id INTEGER, name TEXT)")
array rows = handle.query("SELECT * FROM users")

On each package page these are listed under "Returned object" headings.

The standard library at a glance

Web & networking

Package
Description

HTTP server / web framework (routing, middleware, contexts).

WebSocket client and server.

Bot framework for OriginChats servers.

HTTP client (get/post/put/…).

Low-level TCP/UDP sockets and DNS lookups.

URL parsing, building and query-string handling.

FTP file transfers.

SSH connections, remote commands and SCP.

S3-compatible object storage client.

Web Push notifications (VAPID).

Data & serialization

Package
Description

JSON parsing and encoding.

YAML parsing and encoding.

CSV parsing plus a small dataframe-style toolkit.

XML parsing and querying.

Lightweight {{ }} templating with HTML escaping.

MIME-type lookup and parsing.

Text/line/word diffing.

Databases & storage

Package
Description

Embedded SQLite - SQL plus a document/collection API.

Simple persistent key-value storage.

In-memory LRU cache with TTLs.

Environment variables and .env files.

Filesystem & system

Package
Description

Files, directories and path utilities.

System info, environment, and running shell commands.

Spawn, manage and signal processes.

ZIP / TAR / GZIP compression.

Crypto & security

Package
Description

Hashing, HMAC, AES, password hashing, file encryption, random.

JSON Web Token signing and verification.

Text, math & time

Package
Description

Regular expressions plus validators and text helpers.

Semantic-version parsing and comparison.

Maths, statistics and number theory.

Seedable pseudo-random numbers.

Dates, durations and time zones.

Cron-style job scheduling.

Terminal & logging

Package
Description

Terminal UI: colours, boxes, tables, prompts, menus, charts.

Levelled, colourful logging.

Desktop notifications.

Media & documents

Package
Description

Load, transform and save images.

QR codes and barcodes.

Generate PDF documents.

In-memory pixel canvas.

Build colour values (used by image-producing packages).

Audio playback.

Graphics & windowing

Package
Description

Open a window and draw to it (the originOS graphics model).

Scripting & concurrency

Package
Description

Embed and run Lua scripts.

Background threads.

Named locks for synchronisation.

Utilities & data structures

Package
Description

An ordered key-value map type.

A set type.

Optional values (some/none).

Success/error result values.

Low-level pointer operations.

More

Package
Description

Compose and send email (SMTP).

Create and parse .torrent files.


To read a package's source directly from the CLI:

Last updated