Skip to content

[tools] Pin protoc plugins and the Go version they're built with - #1528

Merged
manugarg merged 1 commit into
mainfrom
pin_protoc_plugins
Oct 5, 2026
Merged

manugarg merged 1 commit into
mainfrom
pin_protoc_plugins

Conversation

@manugarg

@manugarg manugarg commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Generated protobuf code depends on the Go version that protoc-gen-go is built with. With protoc 33.5 and protoc-gen-go v1.36.12:

Go version building protoc-gen-go .pb.go files changed on main
1.23, 1.24, 1.25, 1.26.6 0
1.27.0 26 (comment formatting only)

go install ...@latest builds the plugin with the locally installed Go, not the version in go.mod, so running tools/gen_pb_go.sh with Go 1.27 installed produces unrelated diffs (#1527).

This change:

  • Builds the plugins with the Go version from go.mod (through GOTOOLCHAIN).
  • Pins protoc-gen-go and protoc-gen-go-grpc to the versions that the checked-in files were generated with, instead of @latest.

Tested by running the script in a clean clone of main with Go 1.26.6 and with GOTOOLCHAIN=go1.27.0: in both cases the plugin is built with go1.26.6 and no generated file changes.

Fixes #1527

Generated protobuf code depends on the Go version that protoc-gen-go is
built with: a plugin built with Go 1.27 formats comments differently,
which changes 26 generated files. Build plugins with the Go version in
go.mod, and pin plugin versions instead of using @latest.

Ref: #1527
@manugarg
manugarg merged commit b0e3d45 into main Oct 5, 2026
13 checks passed
@manugarg
manugarg deleted the pin_protoc_plugins branch October 5, 2026 23:14
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.

tools: keep protobuf generation reproducible and generated files in sync

1 participant