GoogleCloudPlatform / golang-samples

Sample apps and code written for Google Cloud in the Go programming language.
Apache License 2.0
4.32k stars 1.75k forks source link

fix: resolve breaking build #4347

Closed subfuzion closed 2 months ago

subfuzion commented 2 months ago

Beginning with Go 1.21, go mod tidy updates go.mod with Go version in x.y.z format. Our CI builds currently tests with Go 1.20 as the earliest version, which expects x.y format.

This mismatch creates a conflict because our lint/vet action currently uses 1.21 (and thus fail after after detecting a change after running go mod tidy if using the x.y format) or else fail in the Kokoro build on Go 1.20 if using the x.y.z format.

This original version of this PR attempted to remove the mismatch by (temporarily) downgrading the version of go used for linting, but this caused go vet to fail. The latest version of this PR simply cherry picks the last commit that caused this to break with the last working version of main rebased on HEAD (instead of the default merge that GitHub did to bring HEAD up to date), with go mod tidy run manually.

Here's what works for now

  1. To update a sample to Go 1.21, run go get go@1.21 in the package directory
  2. Run go get toolchain@none (or just delete the line as part of the next step)
  3. Manually edit go.mod to change go 1.21.XX to ONLY go 1.21 -- this is required so that the CI build for the current earliest version (1.20) doesn't fail (x.y.z format won't work for 1.20). This issue will go away when we upgrade the earliest version to 1.21.
telpirion commented 2 months ago

Thank you @subfuzion -- Just to confirm that a quorum of Gophers (you, me, and @grayside ) met and agreed this was the best path forward.