Artifact 0ed38ec9ea5235dced89d09edb6894e543142d6961305eeb514581a8c890bf86:
- File
examples/tinygo/main.go
— part of check-in
[0650171d55]
at
2026-10-23 21:25:20
on branch main
— feat(wasm): build the whole public API with TinyGo
go-libfossil compiled for js/wasm only with the standard toolchain, whose output is about 16 MB, too large to ship with a page or an edge function. Three standard-library features TinyGo lacks kept it from building there: http.ErrUseLastResponse and net.DNSError in the sync client, and os.SameFile in checkout-marker recovery.
Each now sits behind a tinygo build tag. Under TinyGo a sync redirect ends the request with an error instead of being followed, DNS failures are not classified as transient, and two names of one checkout marker are reported as ambiguous rather than paired; the standard build is unchanged.
examples/tinygo exercises the whole public API, sync and signing included. Built with TinyGo 0.43 and wasm-opt -Oz it is 3.83 MB raw and 1.40 MB gzipped, against 16.1 MB and 4.06 MB from the standard toolchain. A new CI job builds it with TinyGo on every change. (user: [email protected], size: 977) [annotate] [blame] [check-ins using] [more...]
// 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. package main import ( "context" "log" "github.com/danmestas/go-libfossil" ) func main() { r, err := libfossil.Open("notes.fossil") if err != nil { log.Fatalf("open: %v", err) } defer r.Close() t := libfossil.NewHTTPTransport("https://example.org/notes") res, err := r.Sync(context.Background(), t, libfossil.SyncOpts{Pull: true}) if err != nil { log.Fatalf("sync: %v", err) } log.Printf("pulled %d artifacts in %d rounds", res.FilesRecvd, res.Rounds) }