Establish v2 module with subdirectory go.mod
Context
Establishes the v2 Go module for LabKit using the major version subdirectory approach as discussed in gitlab-org#21020 (closed).
What's in this MR?
- Add
v2/go.moddeclaringmodule gitlab.com/gitlab-org/labkit/v2 - Move
fieldsintov2/fields/and update v2 imports to use it, removing cross-module v1 dependencies that cause ambiguous import errors - Refactor CI scripts (
compile.sh,test.sh) to build and test both v1 and v2 modules, withtest.shusing$CIto switch between-race(CI) and-short(local/pre-commit) - Add
go-mod-tidy.shandgolangci-lint.shwrapper scripts and override the corresponding pre-commit hooks so they cover both modules - Run
go mod tidyon the root module to remove unused otel dependencies left over from the v2/trace merge
v1 code at the root is untouched, no existing consumers are affected.
How it works
The major version subdirectory pattern allows v1 and v2 to coexist in the same repo. Consumers can adopt v2 packages incrementally:
import (
logv1 "gitlab.com/gitlab-org/labkit/log" // v1 (logrus)
logv2 "gitlab.com/gitlab-org/labkit/v2/log" // v2 (slog)
)
Related
Edited by Doug Barrett