VSCode搭建Go开发环境
博客
- VSCode搭建Go开发环境
环境变量
linux 下环境变量
GOROOT(安装目录)、 GOPATH(工作目录)、GOBIN(可执行文件目录)、 PATH(环境变量)
vi /etc/profile
Go setting
export GOROOT=/usr/local/go
export GOPATH=~/golib:~/goproject
export GOBIN=~/gobin
export PATH=$PATH:$GOROOT/bin:$GOBIN
配置
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
还没有评论,来说两句吧...