Documentation
¶
Overview ¶
Package gosdk 提供查找本机 go sdk 路径的功能
Index ¶
- func AutoDisableGoWork() error
- func Default(ctx context.Context) string
- func DefaultOrLatest(ctx context.Context) string
- func GoCmdEnv(goBin string, env []string) []string
- func Latest(ctx context.Context) string
- func LatestOrDefault(ctx context.Context) string
- func List(ctx context.Context) []string
- func MustAutoDisableGoWork()
- func RunGo(ctx context.Context, root string)
- func SetLogger(l *log.Logger)
- func TryAutoDisableGoWork()
- func Update()
- type SDK
- func (gs *SDK) Default(ctx context.Context) string
- func (gs *SDK) DefaultOrLatest(ctx context.Context) string
- func (gs *SDK) Find(ctx context.Context, version string) string
- func (gs *SDK) Latest(ctx context.Context) string
- func (gs *SDK) LatestOrDefault(ctx context.Context) string
- func (gs *SDK) List(ctx context.Context) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AutoDisableGoWork ¶ added in v0.0.3
func AutoDisableGoWork() error
AutoDisableGoWork 自动禁用 go work 功能
若当前项目未在 go.work 文件中定义,则设置环境变量 GOWORK = off
func DefaultOrLatest ¶
DefaultOrLatest 查找 $PATH 里的 "go" 二进制文件的路径 或者是最高版本的 go 若没有,也会返回 "go"
func LatestOrDefault ¶
LatestOrDefault 返回最新版本,或者是 $PATH 里的 go 版本, 若没有,也会返回 "go"
func MustAutoDisableGoWork ¶ added in v0.0.3
func MustAutoDisableGoWork()
MustAutoDisableGoWork AutoDisableGoWork 的快捷调用,若失败会 panic
func TryAutoDisableGoWork ¶ added in v0.0.3
func TryAutoDisableGoWork()
TryAutoDisableGoWork AutoDisableGoWork 的快捷调用,若失败,会打印日志
Types ¶
type SDK ¶
type SDK struct {
ExtDirs []string // 除了 ~/sdk/ 其他的 go sdk 根目录,可选
// contains filtered or unexported fields
}
SDK 查找当前机器的 Go SDK 情况
func (*SDK) DefaultOrLatest ¶
DefaultOrLatest 查找 $PATH 里的 go 或者是最高版本的 go 若没有,也会返回 "go"
func (*SDK) Find ¶ added in v0.0.6
Find 查找指定号的 go 命令的地址,若查找不到会返回空字符串
version: go 版本号,如 1.21
返回如 /home/work/sdk/go1.21.12/bin/go
func (*SDK) LatestOrDefault ¶
LatestOrDefault 返回最新版本 "go" 二进制文件的路径,或者是 $PATH 里的 go 版本 若没有,也会返回 "go"
Click to show internal directories.
Click to hide internal directories.