3
【笔记】Go配置环境变量
source link: https://loli.fj.cn/2023/04/16/Go%E9%85%8D%E7%BD%AE%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Go配置环境变量
查看Go环境变量
go env
修改Go环境变量
go env -w <key>=<value>
配置GOROOT
- 指定Go的安装位置
go env -w GOROOT="/usr/local/go"
配置GOPATH
- 当GOPATH管理项目时,指定Go项目的根目录
Linux/MacOS默认在~/go
Windows默认在c:\go
go env -w GOPATH=""
配置GO代理
- 下载Go模块时候的代理地址
<proxy>
:代理地址
https://proxy.golang.org,direct
:缺省值,官方代理https://goproxy.io,direct
:国内代理https://goproxy.cn,direct
:七牛云国内代理https://mirrors.aliyun.com/groxy,direct
:阿里云国内代理
go env -w GOPROXY="<proxy>"
配置项目依赖管理方式
""
:缺省值,不配置项目管理项目依赖方式on
:使用GOMOD的方式管理项目依赖off
:使用GOPATH的方式管理项目依赖auto
:自动识别管理项目依赖方式
go env -w GO111MODULE=on
通过系统环境变量配置Go环境变量
Linux/MacOS
export <key>="<value>"
Windows
Powershell
$env:<key> = "<value>"
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK