Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ module github.com/databricks/databricks-sql-go

go 1.25.0

// gotestsum is a build-time test runner (see the Makefile's test/coverage
// targets), not a library the driver imports. The tool directive (Go 1.24+)
// keeps it in the module graph — the job the old //go:build tools file did —
// without declaring a second package in the module root.
//
// See https://github.com/databricks/databricks-sql-go/issues/162.
tool gotest.tools/gotestsum

require (
github.com/apache/arrow/go/v12 v12.0.1
github.com/apache/thrift v0.23.0
Expand All @@ -12,7 +20,6 @@ require (
github.com/pierrec/lz4/v4 v4.1.15
github.com/stretchr/testify v1.8.1
golang.org/x/oauth2 v0.27.0
gotest.tools/gotestsum v1.8.2
)

require (
Expand Down Expand Up @@ -43,6 +50,7 @@ require (
golang.org/x/tools v0.6.0 // indirect
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/gotestsum v1.8.2 // indirect
)

require (
Expand Down
7 changes: 0 additions & 7 deletions tools.go

This file was deleted.

30 changes: 30 additions & 0 deletions tools_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package dbsql

import (
"go/build"
"testing"
)

// TestModuleRootIsASinglePackage guards the fix for #162: the module root must
// declare exactly one package no matter which build tags are in play.
//
// The build-time test runner used to be pinned by a `//go:build tools` file
// declaring `package tools` next to `package dbsql`. Tooling that resolves a
// directory's package without honoring build constraints (bazel/gazelle) — or
// that deliberately enables the `tools` tag (golangci-lint) — then saw two
// package names in one directory and failed to load the driver. gotestsum is
// pinned by the go.mod `tool` directive instead, so nothing but `dbsql` lives
// here.
func TestModuleRootIsASinglePackage(t *testing.T) {
ctx := build.Default
// Any tag a consumer might enable must not conjure a second package; "tools"
// is the one that historically did.
ctx.BuildTags = append(ctx.BuildTags, "tools")

if _, err := ctx.ImportDir(".", 0); err != nil {
if _, multiple := err.(*build.MultiplePackageError); multiple {
t.Fatalf("module root declares more than one package: %v", err)
}
t.Fatalf("could not load the module root: %v", err)
}
}