Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bin directory to the PATH for go commands #416

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading