Restore config loading, keep exported Version, keep cgo off

Bring back the in-progress viper and go-homedir configuration loading
from the original root command as a persistent pre-run on the root
command, with a --config flag and a config line in sutil info. Restore
the exported main.Version with a nolint directive instead of renaming
it. Export CGO_ENABLED=0 from the Makefile, drop -race from make test,
and remove the C toolchain from the Docker builder stage.
This commit is contained in:
2026-10-31 10:11:47 -07:00
parent f53b6aad42
commit 4d45aa4ca3
9 changed files with 243 additions and 25 deletions
+7 -3
View File
@@ -9,7 +9,7 @@
BINARY := sutil
VERSION := $(shell git describe --always --dirty 2>/dev/null || echo dev)
GOLDFLAGS := -X main.version=$(VERSION)
GOLDFLAGS := -X main.Version=$(VERSION)
GO_DIRS := cmd internal pkg
# golangci/golangci-lint:v2.12.2, 2026-05-06
@@ -25,6 +25,10 @@ MARKDOWN_GLOB := '**/*.md'
all: build
# cgo stays off everywhere: builds are static and the tests do not use
# -race, which would require a C toolchain.
export CGO_ENABLED := 0
# Build the sutil binary in the repo root with the git version embedded.
build:
go build -trimpath -ldflags "$(GOLDFLAGS)" -o $(BINARY) ./cmd/$(BINARY)
@@ -36,9 +40,9 @@ install:
# Run the tests quietly; on failure rerun verbosely for diagnostics and
# still fail.
test:
@go test -timeout 30s -race -cover ./... || \
@go test -timeout 30s -cover ./... || \
{ echo "--- Rerunning with -v for details ---"; \
go test -timeout 30s -race -v ./...; exit 1; }
go test -timeout 30s -v ./...; exit 1; }
# Lint with the pinned golangci-lint image when docker is available so local
# results match CI exactly. Inside the Docker build (where there is no