mac brew golang多版本操作记录
brew
🍺 The missing package manager for macOS (or Linux)
项目地址:https://gitcode.com/gh_mirrors/br/brew

·
一、使用brew前先更新:brew update
1.解除绑定:brew unlink go
2.下载版本:brew install go@1.17
3.绑定关系:brew link go@1.17
4.确定绑定:go version
二、其余:
1.查看brew安装列表:brew ls
2.查找依赖:brew search 依赖名
3.更新版本:通过search 查看是否安装依赖,unlink解除当前版本,link绑定新版本
三、后遗症
go 1.10版本切换go1.17以上版本,项目中使用go mod建立依赖配置如下:
go env -w GO111MODULE="on"
go env -w GOPATH=""
终端重启 go run
四、GO111MODULE配置相关
GO111MODULE="on" 不会去GOPATH目录下查找,会使用modules
GO111MODULE=off 不会使用module,以旧版本目录或者GOPATH来查找
GO111MODULE=auto,默认值,根据当前目录决定是否启用module功能
分两种情况:
当前目录在GOPATH/SRC之外且该目录包含go.mod文件
当前文件在包含go.mod文件的目录下面
五、go.mod常用
go mod init 项目名: 初始mod
go mod tidy: 拉去依赖,移除不用模块
go mod edit: 编辑mod




🍺 The missing package manager for macOS (or Linux)
最近提交(Master分支:5 个月前 )
c8d8c09d
Add `brew update-if-needed`
8 小时前
5ec5063d
This uses the logic in `brew.sh` for deciding whether or not to run
`brew update --auto-update` and makes it a dedicated command that can
be used instead of `brew update` in scripts to be really fast in the
no-op case.
`brew update` will always do at least some updating which is a nicer
default but is much slower.
9 小时前
更多推荐
所有评论(0)