Skip to content

Commit

Permalink
Add bin directory to the PATH for go commands (#416)
Browse files Browse the repository at this point in the history
* Add `bin` directory to the PATH for go commands

* Merge master into wojtek/bin-path
  • Loading branch information
wojtek-coreum authored Jun 14, 2024
1 parent cf038db commit ab28030
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions build/golang/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"strings"

"github.com/pkg/errors"
"github.com/samber/lo"
"go.uber.org/zap"

"github.com/CoreumFoundation/coreum-tools/pkg/libexec"
Expand Down Expand Up @@ -80,11 +81,12 @@ func env() []string {
envVars := make([]string, 0, len(osEnv))
for _, envVar := range osEnv {
e := strings.ToUpper(envVar)
if !strings.Contains(e, "GOROOT=") && !strings.Contains(e, "GOPATH=") {
if !strings.Contains(e, "GOROOT=") && !strings.Contains(e, "GOPATH=") &&
!strings.Contains(e, "PATH=") {
envVars = append(envVars, envVar)
}
}
return envVars
return append(envVars, "PATH="+lo.Must1(filepath.Abs(filepath.Join(repoPath, "bin")))+":"+os.Getenv("PATH"))
}

// EnsureGo ensures that go is available.
Expand Down Expand Up @@ -309,6 +311,7 @@ func buildArgsAndEnvs(
func Generate(ctx context.Context, deps types.DepsFunc) error {
deps(EnsureGo)
log := logger.Get(ctx)

return onModule(repoPath, func(path string) error {
log.Info("Running go generate", zap.String("path", path))

Expand Down

0 comments on commit ab28030

Please sign in to comment.