mukan-ignite/ignite/pkg/goenv/goenv.go
Mukan Erkin Törük 26b204bd04
Some checks are pending
Docs Deploy / build_and_deploy (push) Waiting to run
Generate Docs / cli (push) Waiting to run
Generate Config Doc / cli (push) Waiting to run
Go formatting / go-formatting (push) Waiting to run
Check links / markdown-link-check (push) Waiting to run
Integration / pre-test (push) Waiting to run
Integration / test on (push) Blocked by required conditions
Integration / status (push) Blocked by required conditions
Lint / Lint Go code (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
feat: fork Ignite CLI v29 as Mukan Ignite — remove cosmos-sdk restrictions
2026-05-11 03:31:37 +03:00

62 lines
1.3 KiB
Go

// Package goenv defines env variables known by Go and some utilities around it.
package goenv
import (
"fmt"
"go/build"
"os"
"path/filepath"
)
const (
// GOBIN is the env var for GOBIN.
GOBIN = "GOBIN"
// GOPATH is the env var for GOPATH.
GOPATH = "GOPATH"
// GOMODCACHE is the env var for GOMODCACHE.
GOMODCACHE = "GOMODCACHE"
)
const (
binDir = "bin"
modDir = "pkg/mod"
)
// Bin returns the path of where Go binaries are installed.
func Bin() string {
if binPath := os.Getenv(GOBIN); binPath != "" {
return binPath
}
if goPath := os.Getenv(GOPATH); goPath != "" {
return filepath.Join(goPath, binDir)
}
return filepath.Join(build.Default.GOPATH, binDir)
}
// Path returns $PATH with correct go bin configuration set.
func Path() string {
return os.ExpandEnv(fmt.Sprintf("$PATH:%s", Bin()))
}
// ConfigurePath configures the env with correct $PATH that has go bin setup.
func ConfigurePath() error {
return os.Setenv("PATH", Path())
}
// GoModCache returns the path to Go's module cache.
func GoModCache() string {
if path := os.Getenv(GOMODCACHE); path != "" {
return path
}
if path := os.Getenv(GOPATH); path != "" {
return filepath.Join(path, modDir)
}
return filepath.Join(build.Default.GOPATH, modDir)
}
// GoPath returns the go path.
func GoPath() string {
return os.Getenv(GOPATH)
}