Help us shape the future of Go! Take the 2026 Go Developer Survey

tinygo

command
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 4 Imported by: 0

README

tinygo (js/wasm)

The whole public API, including the HTTP sync client and signing, compiled with TinyGo for the wasm (js) target.

tinygo build -target=wasm -no-debug -opt=z -stack-size=1MB -o libfossil.wasm ./examples/tinygo/
wasm-opt -Oz --detect-features --strip-debug --strip-producers libfossil.wasm -o libfossil.wasm

-stack-size=1MB: TinyGo's default goroutine stack is too small for go-libfossil's deeper paths.

Measured for this program with TinyGo 0.43.0: the first row is the Build (tinygo) CI job; the others are macOS (Go 1.27.3, LLVM 22, Binaryen 133).

Build Raw gzip -9
TinyGo, as CI builds it (Linux release, its own wasm-opt) 3.52 MB 1.26 MB
TinyGo, then wasm-opt -Oz 3.83 MB 1.40 MB
TinyGo 4.02 MB 1.44 MB
Standard Go, GOOS=js GOARCH=wasm -ldflags='-s -w' 16.1 MB 4.06 MB

A program that leaves out sync (no net/http, no TLS) is smaller.

A library embedder that never uses the HTTP transport or server can build with -tags libfossil_nohttp, which leaves net/http and its TLS code out (about 97 KB gzipped). This example does not build with that tag, since it calls NewHTTPTransport, and neither does the cli package. A tagged embedder supplies its own transport and serving, for example a Transport for Sync and its own request handling around HandleSyncWithOpts.

-tags libfossil_noslog leaves log/slog out (about 33 KB gzipped): the check-in linker writes its info and warning messages to stderr instead and drops its debug messages. This example builds with it. For a program that needs to be smaller still, see "Smaller still" in the install guide.

No SQLite driver is imported here. A TinyGo host registers a database/sql driver over its own SQLite. The ncruces driver runs SQLite as an embedded wasm module and is for standard Go builds; the modernc driver has no wasm build.

Under TinyGo two things behave differently, because TinyGo's standard library lacks what they use: a sync redirect ends the request with an error instead of being followed, and DNS failures are not classified as transient.

Documentation

Overview

Example: the whole public API, sync included, built with TinyGo for the js/wasm target, as an application ships go-libfossil to a browser or an edge runtime.

It imports no SQLite driver. A TinyGo host supplies one for its own storage (a database/sql driver over the host's SQLite) and registers it; the ncruces driver, which embeds SQLite as a wasm module run by an interpreter, is for standard Go builds. CI builds this example with TinyGo so the module keeps compiling there.

It imports sshverify, which links SSH signature verification, so the build covers a store whose horizon-seed-key is an SSH key. An application that never verifies an SSH signature leaves it out and is smaller.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL