Skip to content

Commit

Permalink
Revert select gomod version changes (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
brayanhenao authored May 10, 2022
1 parent 0b73d7d commit 7f739b1
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions src/go/supply/supply.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/Masterminds/semver"
"github.com/cloudfoundry/go-buildpack/src/go/data"
"github.com/cloudfoundry/go-buildpack/src/go/godep"
"github.com/cloudfoundry/go-buildpack/src/go/gomod"
"github.com/cloudfoundry/go-buildpack/src/go/warnings"
"github.com/cloudfoundry/libbuildpack"
)
Expand Down Expand Up @@ -45,7 +44,6 @@ type Supplier struct {
VendorTool string
GoVersion string
Godep godep.Godep
GoMod gomod.GoMod
}

func Run(gs *Supplier) error {
Expand Down Expand Up @@ -95,15 +93,9 @@ func (gs *Supplier) SelectVendorTool() error {
return errors.New(".godir deprecated")
}

isGoMod, err := libbuildpack.FileExists(filepath.Join(gs.Stager.BuildDir(), "go.mod"))
if err != nil {
if exists, err := libbuildpack.FileExists(filepath.Join(gs.Stager.BuildDir(), "go.mod")); err != nil {
return err
}
if isGoMod {
gs.Log.BeginStep("Checking go.mod file")
if err := gs.GoMod.Load(filepath.Join(gs.Stager.BuildDir(), "go.mod")); err != nil {
gs.Log.Error("Unable to load go version from go.mod: %s", err)
}
} else if exists {
gs.Stager.WriteEnvFile("GO111MODULE", "on")
gs.VendorTool = "gomod"
return nil
Expand Down Expand Up @@ -183,16 +175,12 @@ func (gs *Supplier) InstallVendorTools() error {

func (gs *Supplier) SelectGoVersion() error {
goVersion := os.Getenv("GOVERSION")
if gs.VendorTool == "godep" || gs.VendorTool == "gomod" {

if gs.VendorTool == "godep" {
if goVersion != "" {
gs.Log.Warning(warnings.GoVersionOverride(goVersion))
} else {
switch gs.VendorTool {
case "godep":
goVersion = gs.Godep.GoVersion
case "gomod":
goVersion = gs.GoMod.GoVersion
}
goVersion = gs.Godep.GoVersion
}
} else {
if goVersion == "" {
Expand Down Expand Up @@ -331,4 +319,4 @@ func isGoFile(path string, info os.FileInfo, err error) error {
}

return nil
}
}

0 comments on commit 7f739b1

Please sign in to comment.