Skip to content

Commit

Permalink
Don't use go.mod to detect go version
Browse files Browse the repository at this point in the history
The declaration in go.mod is intended indicate the minimum compatible version:
https://go.dev/doc/modules/gomod-ref#go

The current logic is treating like an exact version specifier

PiperOrigin-RevId: 423183372
Change-Id: Ia522cdf1a5c89bedce6976b59a5e811c386f6c4c
  • Loading branch information
matthewrobertson authored and copybara-github committed Jan 21, 2022
1 parent 494e729 commit 9b81ec3
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 6 deletions.
1 change: 1 addition & 0 deletions builders/gcp/base/acceptance/go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func TestAcceptanceGo(t *testing.T) {
App: "go/simple_gomod",
MustUse: []string{goRuntime, goBuild},
MustNotUse: []string{goPath},
MustOutput: []string{"Using latest runtime version:"},
},
{
Name: "Go.mod package",
Expand Down
1 change: 1 addition & 0 deletions builders/testdata/generic/go/simple_gomod/go.mod
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
module example.com/package

go 1.14
1 change: 0 additions & 1 deletion cmd/go/runtime/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ go_binary(
deps = [
"//pkg/env",
"//pkg/gcpbuildpack",
"//pkg/golang",
"//pkg/runtime",
"@com_github_buildpacks_libcnb//:go_default_library",
],
Expand Down
5 changes: 0 additions & 5 deletions cmd/go/runtime/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (

"github.com/GoogleCloudPlatform/buildpacks/pkg/env"
gcp "github.com/GoogleCloudPlatform/buildpacks/pkg/gcpbuildpack"
"github.com/GoogleCloudPlatform/buildpacks/pkg/golang"
"github.com/GoogleCloudPlatform/buildpacks/pkg/runtime"
"github.com/buildpacks/libcnb"
)
Expand Down Expand Up @@ -95,10 +94,6 @@ func runtimeVersion(ctx *gcp.Context) (string, error) {
ctx.Logf("Using runtime version from %s: %s", env.RuntimeVersion, version)
return version, nil
}
if version := golang.GoModVersion(ctx); version != "" {
ctx.Logf("Using runtime version from go.mod: %s", version)
return version, nil
}
version, err := latestGoVersion(ctx)
if err != nil {
return "", fmt.Errorf("getting latest version: %w", err)
Expand Down

0 comments on commit 9b81ec3

Please sign in to comment.