Skip to content

Commit 3ef7510

Browse files
committed
Add CGO build constraints for DuckDB support
DuckDB requires CGO (via go-duckdb C bindings), but CI builds with CGO_ENABLED=0. This commit adds proper build constraints to ensure sqlc builds successfully with or without CGO. Changes: - Move go-duckdb import to separate files with //go:build cgo constraint - internal/cmd/vet_duckdb.go: DuckDB driver import (only with CGO) - internal/engine/duckdb/analyzer/driver.go: DuckDB driver import (only with CGO) - Remove go-duckdb import from main vet.go and analyze.go files Build verification: ✅ CGO_ENABLED=1: Full DuckDB support, 121MB binary ✅ CGO_ENABLED=0: DuckDB excluded, 73MB binary (48MB smaller) ✅ Tests pass with CGO enabled ✅ Build succeeds with CGO disabled (CI requirement) The cgo build tag automatically excludes these files when CGO is disabled, allowing sqlc to build on all platforms while providing DuckDB support when CGO is available. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 0334db5 commit 3ef7510

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

internal/cmd/vet.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"github.com/google/cel-go/cel"
2222
"github.com/google/cel-go/ext"
2323
"github.com/jackc/pgx/v5"
24-
_ "github.com/marcboeker/go-duckdb"
2524
"github.com/spf13/cobra"
2625
"google.golang.org/protobuf/encoding/protojson"
2726

internal/cmd/vet_duckdb.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//go:build cgo
2+
3+
package cmd
4+
5+
import (
6+
_ "github.com/marcboeker/go-duckdb"
7+
)

internal/engine/duckdb/analyzer/analyze.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import (
88
"strings"
99
"sync"
1010

11-
_ "github.com/marcboeker/go-duckdb"
12-
1311
core "github.com/sqlc-dev/sqlc/internal/analysis"
1412
"github.com/sqlc-dev/sqlc/internal/config"
1513
"github.com/sqlc-dev/sqlc/internal/dbmanager"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//go:build cgo
2+
3+
package analyzer
4+
5+
import (
6+
_ "github.com/marcboeker/go-duckdb"
7+
)

0 commit comments

Comments
 (0)