Skip to content
go-libfossil Artifact [e643ad263a]
Login

Artifact [e643ad263a]

Artifact e643ad263a8a1649e8c86e029e180a0fd0f1624f1e2665508a5a99f5649b6bcd:


embed-repo-api

A minimal example showing how to embed libfossil as a library in a Go application. It walks the basic repo lifecycle:

  1. Register the default pure-Go SQLite driver via blank import (_ "github.com/danmestas/libfossil/db/driver/modernc").
  2. Create a new .fossil repository in a temp directory with libfossil.Create.
  3. Close the handle returned by Create and re-open the file from disk with libfossil.Open to show the two calls are distinct.
  4. Make one commit via repo.Commit, then read back:
    • the project-code config value (repo.Config)
    • the timeline of checkins (repo.Timeline)
    • the files in the manifest (repo.ListFiles)
  5. Close the repo and remove the temp directory.

Running

This example lives inside the root github.com/danmestas/libfossil module, so no separate go.mod is needed.

From the repo root:

go run ./examples/embed-repo-api

or:

go build ./examples/embed-repo-api

Expected output includes log lines for the created repo path, the commit RID and UUID, the project-code, one timeline entry, and one file entry (hello.txt).