Make the Go module fetchable from its directory

Merged
IL
6h ago
+226-226

Summary

The Go module lives in src/go but declares the path github.com/netdata/plugin-ipc/go. The go command looks for a module's go.mod in the directory its path names, so the module cannot be fetched from this repository:

$ go list -m github.com/netdata/plugin-ipc/go@<commit>
go: ... invalid version: missing github.com/netdata/plugin-ipc/go/go.mod at revision <commit>

This PR declares the module as github.com/netdata/plugin-ipc/src/go, the path that matches its directory. It is a path change only:

  • src/go/go.mod and every import in src/go.
  • The require and replace lines and the imports of the fixture and bench modules (tests/fixtures/go, bench/drivers/go).
  • The getting started example.
  • The import paths that vendor-to-netdata.sh, diff-netdata-vendor.sh and the vendoring skill rewrite or normalize.

The directory layout, the C and Rust trees and the CI workflows are unchanged. Every changed line is the old path replaced by the new one.

Why

Consumers can then require the module at a commit like any other Go dependency. Netdata plans to do that for the Go side instead of vendoring the Go tree; nothing in Netdata imports the vendored Go copy today. The C and Rust vendoring is not affected, and the vendoring scripts keep working as they are.

What changes for consumers

  • Imports become github.com/netdata/plugin-ipc/src/go/pkg/netipc/....
  • A vendored copy with rewritten import paths (the current Netdata setup) is not affected: the scripts rewrite the new path the same way.

Validation

  • src/go: go build, go vet, go test -race ./..., and the Windows test compile.
  • tests/fixtures/go: builds, tests pass. bench/drivers/go: go vet for Linux and Windows.
  • gofmt reports nothing.
  • Fetch check against a local copy of the repository: github.com/netdata/plugin-ipc/src/go resolves at this commit, and a consumer module that requires it builds for Linux, macOS and Windows.
  • Not checked before pushing: the public module proxy and checksum database, which need the commit in this repository.

Notes for the reviewer

  • Open PRs that add Go files with the old import path need the path updated when they take main.
  • Once Netdata requires the module, the Go section of the vendoring scripts has no user left and can be removed in a follow-up.

Summary by cubic

Renames the Go module to github.com/netdata/plugin-ipc/src/go so it matches its directory in this repository and can be fetched with go get.

Previously the module declared github.com/netdata/plugin-ipc/go, but the go command looks for go.mod in the directory the path names, so fetching failed. This is a path-only change: go.mod, every import in src/go, the fixture and bench modules, the getting started example, and the paths the vendoring scripts and skill rewrite or normalize are updated. Consumers now import github.com/netdata/plugin-ipc/src/go/pkg/netipc/...; a vendored copy with rewritten import paths is unaffected.