fix: enable building on Windows without CGO (#1117)

The dolt storage backend requires CGO due to its gozstd dependency.
This change makes the dolt backend optional using build tags, allowing
`go install` to work on Windows where CGO is disabled by default.

Changes:
- Add BackendFactory registration pattern to factory package
- Create factory_dolt.go with `//go:build cgo` constraint that
  registers the dolt backend only when CGO is available
- Update init.go to use factory instead of direct dolt import
- When dolt backend is requested without CGO, provide helpful error
  message directing users to pre-built binaries

The sqlite backend (default) works without CGO and covers the majority
of use cases. Users who need dolt can either:
1. Use pre-built binaries from GitHub releases
2. Enable CGO by installing a C compiler

Fixes #1116
This commit is contained in:
Bobby Johnson
2026-01-15 19:23:02 -08:00
committed by GitHub
parent c1a9dda173
commit 55e733cf62
5 changed files with 125 additions and 9 deletions

2
go.mod
View File

@@ -10,6 +10,7 @@ require (
github.com/charmbracelet/glamour v0.10.0
github.com/charmbracelet/huh v0.8.0
github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834
github.com/dolthub/driver v0.2.0
github.com/fsnotify/fsnotify v1.9.0
github.com/gofrs/flock v0.13.0
github.com/muesli/termenv v0.16.0
@@ -60,7 +61,6 @@ require (
github.com/dlclark/regexp2 v1.11.0 // indirect
github.com/dolthub/dolt/go v0.40.5-0.20240702155756-bcf4dd5f5cc1 // indirect
github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi v0.0.0-20240212175631-02e9f99a3a9b // indirect
github.com/dolthub/driver v0.2.0 // indirect
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2 // indirect
github.com/dolthub/fslock v0.0.3 // indirect
github.com/dolthub/go-icu-regex v0.0.0-20230524105445-af7e7991c97e // indirect