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.mod declaring module gitlab.com/gitlab-org/labkit/v2
  • Move fields into v2/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, with test.sh using $CI to switch between -race (CI) and -short (local/pre-commit)
  • Add go-mod-tidy.sh and golangci-lint.sh wrapper scripts and override the corresponding pre-commit hooks so they cover both modules
  • Run go mod tidy on 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)
)

gitlab-org#21020 (closed)

Edited by Doug Barrett

Merge request reports

Loading