Artifact b4c1910f2b6c41199e49fb9e5fe4f30998af5ab296711bce017773bac613b8f7:
- File
docs/site/content/docs/get-started/install.md
— part of check-in
[9594cf3bae]
at
2026-10-29 03:06:23
on branch main
— perf(wasm): add a libfossil_nohttp build tag that leaves out net/http
Under TinyGo, importing net/http at all links its TLS and X.509 code (crypto/x509, encoding/asn1, math/big's integers, AES-GCM, SHA-3, netip) whether or not a request is ever made: a five-line program that calls only http.StatusText grows by about 430 KB raw. The library imports it for its HTTP client transport and its HTTP server, which a program that serves sync through HandleSyncWithOpts and supplies its own transport never calls.
Built with -tags libfossil_nohttp, the library leaves out NewHTTPTransport, WithHTTPClient, Repo.Pull, Repo.XferHandler and Repo.ServeHTTP, and the internal/sync client, server, redirect handling and peer-address trace they use. HandleSync, HandleSyncWithOpts, Sync over a host Transport and everything else are unchanged. Without the tag nothing changes. The retry classifier keeps the two statuses it read from net/http as constants, and DNS fault classification moves to its own file so it stays in the tagged build.
For the html-artifact-publisher engine (TinyGo 0.43.0, Go 1.26.0) the tag takes the gzipped binary from 1,100,251 to 1,003,279 bytes. A test builds the library, db and simio with the tag for the host and js/wasm and checks none links net/http, net/http/httptrace or crypto/tls, and that the untagged library still does. (user: [email protected], size: 3212) [annotate] [blame] [check-ins using]
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
- Size: for
examples/tinygo, about 1.3 MB gzipped as CI builds it, against about 4.1 MB from the standard toolchain. A program without sync is smaller. - Driver: a TinyGo build imports no SQLite driver. The host registers a
database/sqldriver over its own SQLite; ncruces is for standard Go builds and modernc has no wasm build. - Stack:
-stack-size=1MB, because TinyGo's default goroutine stack is too small for the deeper paths. - Differences: under TinyGo a sync redirect ends the request with an error instead of being followed, and DNS failures are not classified as transient.
- Without HTTP: a program that serves sync through
HandleSyncWithOptsand syncs, if at all, through aTransportits host supplies can build with-tags libfossil_nohttp. That leaves outNewHTTPTransport,WithHTTPClient,Repo.Pull,Repo.XferHandlerandRepo.ServeHTTP, and with themnet/http, whose TLS and X.509 dependencies are about 97 KB of a gzipped TinyGo binary. Everything else is unchanged.
CI builds examples/tinygo with TinyGo 0.43 on every change.