Documentation
¶
Index ¶
- Constants
- Variables
- func Command(name string, arg ...string) (cmd *exec.Cmd, err error)
- func ConfDirPath(opts ...ConfDirPathOption) (confDirPath string, gobinPath string, err error)
- func EnsureGobinCmdInstalled(global bool) (cmdPath string, err error)
- func EnsureInstalled(gobinPath string, pkgPath string, ver string, tags string, log *log.Logger, ...) (cmdPkgVerPath string, err error)
- func GlobalConfDirPath() (confDirPath string, gobinPath string, err error)
- func RunCommand(name string, arg ...string) (execErr *exec.ExitError, err error)
- type ConfDirPathOption
- type GoListOutput
- type PkgVerLockMapT
Constants ¶
View Source
const GobinCmdBase = "gobin"
View Source
const GobinDirBase = ".gobin"
View Source
const ManifestFileBase = "Gobinfile"
View Source
const ManifestLockFileBase = "Gobinfile-lock"
Variables ¶
View Source
var Goroot = sync.OnceValues(func() (gobinPath string, err error) { ver := "1.23.1" homeDir := v(os.UserHomeDir()) sdkDirPath := filepath.Join(homeDir, "sdk") gorootPath := filepath.Join(sdkDirPath, "go"+ver) goCmdPath := filepath.Join(gorootPath, "bin", "go"+exeExt()) if _, err := os.Stat(goCmdPath); err == nil { return gorootPath, nil } tempDir := v(os.MkdirTemp("", "")) defer (func() { v0(os.RemoveAll(tempDir)) })() arcPath := filepath.Join(tempDir, "temp.tgz") url := fmt.Sprintf("https://go.dev/dl/go%s.%s-%s.tar.gz", ver, runtime.GOOS, runtime.GOARCH) if runtime.GOOS == "windows" { arcPath = filepath.Join(tempDir, "temp.zip") url = fmt.Sprintf("https://go.dev/dl/go%s.%s-%s.zip", ver, runtime.GOOS, runtime.GOARCH) } cmd := exec.Command("curl"+exeExt(), "--location", "-o", arcPath, url) cmd.Stdout = os.Stderr cmd.Stderr = os.Stderr v0(cmd.Run()) cmd = exec.Command("tar"+exeExt(), "-C", sdkDirPath, "-xzf", arcPath) cmd.Stdout = os.Stderr cmd.Stderr = os.Stderr v0(cmd.Run()) v0(os.Rename(filepath.Join(sdkDirPath, "go"), gorootPath)) return gorootPath, nil })
Functions ¶
func ConfDirPath ¶
func ConfDirPath(opts ...ConfDirPathOption) ( confDirPath string, gobinPath string, err error, )
ConfDirPath returns the configuration directory path. If the global option is true, it returns the global (home) configuration directory path. This returns the directory which contains the manifest file. If no manifest file is found in any parent directory, it returns the directory which contains the go.mod file.
func EnsureGobinCmdInstalled ¶ added in v0.1.1
func EnsureInstalled ¶
func EnsureInstalled(gobinPath string, pkgPath string, ver string, tags string, log *log.Logger, _ *log.Logger) (cmdPkgVerPath string, err error)
EnsureInstalled ensures that the program package is installed.
func GlobalConfDirPath ¶ added in v0.1.8
Types ¶
type ConfDirPathOption ¶
type ConfDirPathOption func(*paramsT) error
func WithGlobal ¶
func WithGlobal(f bool) ConfDirPathOption
func WithInitialDir ¶
func WithInitialDir(initialDir string) ConfDirPathOption
type GoListOutput ¶
type GoListOutput struct {
Version string `json:"Version"`
}
GoListOutput represents the output of the `go list` command.
type PkgVerLockMapT ¶
func PkgVerLockMap ¶
func PkgVerLockMap(dirPath string) (lockList PkgVerLockMapT, err error)
PkgVerLockMap returns the package version lock map.
Click to show internal directories.
Click to hide internal directories.