博客
环境变量
linux 下环境变量
- GOROOT(安装目录)、 GOPATH(工作目录)、GOBIN(可执行文件目录)、 PATH(环境变量)
- Windows 中在系统变量 Path 中添加 D:\Go\bin
vi /etc/profile
# Go setting
export GOROOT=/usr/local/go
export GOPATH=~/golib:~/goproject
export GOBIN=~/gobin
export PATH=$PATH:$GOROOT/bin:$GOBIN
命令
go env -w GOPATH=D:\go-wk
go env -w GOPROXY=https://goproxy.cn,direct
配置
- launch.json是vscode用于调试的配置文件,比如指定调试语言环境,指定调试类型等等。内容示例如下:
{
"version": "0.2.0",
"configurations": [
{
"name": "LaunchGo",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 5546,
"host": "127.0.0.1",
"program": "${file}", //这个配置成你要调试的文件、${file}当前打开的文件
"env": {
"INFLUXDB_PW":"influxinflux",
"GOPATH": "D:/go-workspace",
"GOROOT": "D:/Go"
},
"args": ["--influxdb.username=influx",
"--influxdb.database=prometheus","--influxdb-url=http://10.130.135.79:8086/"],
//"showLog": true
}
]
}
go mod download 下载模块到本地缓存,缓存路径是 $GOPATH/pkg/mod/cache