Skip to content
go-libfossil Artifact [5b187c9daf]
Login

Artifact [5b187c9daf]

Artifact 5b187c9dafcc0de01aaebec24b6f2b35d89daa8a5a0a8a9fd89e5dc7621085ef:



title: Install

weight: 10

go-libfossil is a Go module and a command. Neither needs cgo, a C toolchain or an installed fossil.

The command

go install github.com/danmestas/go-libfossil/cmd/libfossil@latest
libfossil --help

This needs the Go toolchain named in go.mod (Go 1.26 or later). The binary is statically linked and runs on Linux, macOS and Windows. Every command is listed in the CLI reference.

The library

go get github.com/danmestas/go-libfossil@latest

The library talks to SQLite through database/sql and does not pick a driver for you. Blank-import exactly one of the two driver modules in your main package; importing both panics at start-up.

Driver Import Use it for
modernc _ "github.com/danmestas/go-libfossil/db/driver/modernc" servers, command-line tools, desktop: SQLite translated to Go
ncruces _ "github.com/danmestas/go-libfossil/db/driver/ncruces" GOOS=js and GOOS=wasip1 builds: SQLite itself as WebAssembly

Each driver is its own module, so go get it too:

go get github.com/danmestas/go-libfossil/db/driver/modernc@latest

WebAssembly

With the ncruces driver the module builds for GOOS=js GOARCH=wasm (a browser) and GOOS=wasip1 GOARCH=wasm (any WASI Preview 1 host). CI builds the module's packages for js/wasm on every change. The wasm example builds and runs a WASI module.

TinyGo

The whole public API, the HTTP sync client and signing included, also builds with TinyGo for the wasm target, which is what makes it small enough to ship with a page or an edge function:

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

CI builds examples/tinygo with TinyGo 0.43 on every change, and builds the library under both tags.

Smaller still

The html-artifact-publisher engine, which serves Fossil repositories from Cloudflare Durable Objects, uses both tags and goes further. It is 754,725 bytes gzipped with TinyGo 0.43 and Go 1.27.3, where the same program built as above is about 1.2 MB; in the publisher's measurements on Go 1.26 it also ran its test workload about three times faster. Its fossil/build.sh is the worked example. Beyond the tags it:

These steps are the publisher's, not the library's, and this repository's CI does not build that way. They hold for a program that, like the publisher's engine, opens repositories, commits and serves sync through HandleSyncWithOpts; other paths, such as the HTTP sync client, may start goroutines of their own that such a build cannot run.

Next