Quickstart
Quickstart
A five-minute tour of libfossil: clone a repo and read its history from Go.
Install
go install github.com/danmestas/libfossil/cmd/libfossil@latest
libfossil --helpThe binary is pure-Go and CGo-free — drop it on any host.
Clone a repository
Clone using the Go API:
package main
import (
"context"
"log"
"github.com/danmestas/libfossil"
)
func main() {
t := libfossil.NewHTTPTransport("https://example.com/repo.fossil")
repo, _, err := libfossil.Clone(context.Background(), "./repo.fossil", t, libfossil.CloneOpts{})
if err != nil {
log.Fatal(err)
}
defer repo.Close()
}Open from Go
After cloning (above), open the same .fossil file from Go and read its history:
package main
import (
"fmt"
"log"
"github.com/danmestas/libfossil"
)
func main() {
repo, err := libfossil.Open("repo.fossil")
if err != nil {
log.Fatal(err)
}
defer repo.Close()
entries, err := repo.Timeline(libfossil.LogOpts{Limit: 10})
if err != nil {
log.Fatal(err)
}
for _, e := range entries {
fmt.Println(e.UUID, e.Comment)
}
}Sync over HTTP
package main
import (
"context"
"log"
"github.com/danmestas/libfossil"
)
func main() {
repo, err := libfossil.Open("repo.fossil")
if err != nil {
log.Fatal(err)
}
defer repo.Close()
t := libfossil.NewHTTPTransport("https://example.com/repo.fossil")
if _, err := repo.Sync(context.Background(), t, libfossil.SyncOpts{Pull: true}); err != nil {
log.Fatal(err)
}
}Or use the simpler Pull wrapper for pull-only workflows:
_, err := repo.Pull(context.Background(), "https://example.com/repo.fossil", libfossil.PullOpts{})Next steps
- Architecture — how the pieces fit
- Production patterns — error handling, context, telemetry beyond
log.Fatal - Extension Points — observers for telemetry, custom SQLite drivers
- Migration from Fossil — command mapping from upstream
- SDK reference — every package, every exported symbol