Skip to content

[build] Add go mod tidy before go mod vendor for Go 1.24 compat#207

Open
rustiqly wants to merge 1 commit intosonic-net:masterfrom
rustiqly:fix/go-mod-tidy
Open

[build] Add go mod tidy before go mod vendor for Go 1.24 compat#207
rustiqly wants to merge 1 commit intosonic-net:masterfrom
rustiqly:fix/go-mod-tidy

Conversation

@rustiqly
Copy link
Contributor

@rustiqly rustiqly commented Mar 8, 2026

Description

[agent]
Add go mod tidy before go mod vendor in Makefile for Go 1.24 compatibility (Debian Trixie).

What I did

Added $(GO) mod tidy before the $(GO) mod vendor call.

Why I did it

Go 1.24 (Debian Trixie) enforces stricter module graph consistency. go mod vendor fails without go mod tidy first when go.mod targets an older Go version. Backward compatible — no-op on Go 1.21 (bookworm).

How I verified it

Built sonic-mgmt-common under Trixie slave with Go 1.24.

Type of change

  • Bug fix

@mssonicbld
Copy link

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Go 1.24 (shipped in Debian Trixie) is stricter about module graph
consistency. Running `go mod vendor` without `go mod tidy` first
fails with module resolution errors when the go.mod was written
for an older Go version.

Add `go mod tidy` before `go mod vendor`. This is backward
compatible — on Go 1.21 (bookworm) it is a no-op.

Signed-off-by: Rustiqly <rustiqly@users.noreply.github.com>
@mssonicbld
Copy link

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@rustiqly
Copy link
Contributor Author

Fixed: go mod tidy now checks if the installed Go version is >= the go.mod directive before running. The CI environment has Go 1.19 but go.mod declares go 1.21, which caused go mod tidy to refuse (maximum version supported by tidy is 1.19). With this fix, tidy is skipped when Go is too old and runs normally on Go >= 1.21.

/azp run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants