Skip to content

Commit 9b81ec3

Browse files
matthewrobertsoncopybara-github
authored andcommitted
Don't use go.mod to detect go version
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
1 parent 494e729 commit 9b81ec3

4 files changed

Lines changed: 2 additions & 6 deletions

File tree

builders/gcp/base/acceptance/go_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func TestAcceptanceGo(t *testing.T) {
4040
App: "go/simple_gomod",
4141
MustUse: []string{goRuntime, goBuild},
4242
MustNotUse: []string{goPath},
43+
MustOutput: []string{"Using latest runtime version:"},
4344
},
4445
{
4546
Name: "Go.mod package",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
module example.com/package
22

3+
go 1.14

cmd/go/runtime/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ go_binary(
2626
deps = [
2727
"//pkg/env",
2828
"//pkg/gcpbuildpack",
29-
"//pkg/golang",
3029
"//pkg/runtime",
3130
"@com_github_buildpacks_libcnb//:go_default_library",
3231
],

cmd/go/runtime/main.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525

2626
"github.com/GoogleCloudPlatform/buildpacks/pkg/env"
2727
gcp "github.com/GoogleCloudPlatform/buildpacks/pkg/gcpbuildpack"
28-
"github.com/GoogleCloudPlatform/buildpacks/pkg/golang"
2928
"github.com/GoogleCloudPlatform/buildpacks/pkg/runtime"
3029
"github.com/buildpacks/libcnb"
3130
)
@@ -95,10 +94,6 @@ func runtimeVersion(ctx *gcp.Context) (string, error) {
9594
ctx.Logf("Using runtime version from %s: %s", env.RuntimeVersion, version)
9695
return version, nil
9796
}
98-
if version := golang.GoModVersion(ctx); version != "" {
99-
ctx.Logf("Using runtime version from go.mod: %s", version)
100-
return version, nil
101-
}
10297
version, err := latestGoVersion(ctx)
10398
if err != nil {
10499
return "", fmt.Errorf("getting latest version: %w", err)

0 commit comments

Comments
 (0)