博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
VSCode搭建Go开发环境
阅读量:4204 次
发布时间:2019-05-26

本文共 1002 字,大约阅读时间需要 3 分钟。

博客

环境变量

linux 下环境变量

  • GOROOT(安装目录)、 GOPATH(工作目录)、GOBIN(可执行文件目录)、 PATH(环境变量)
vi /etc/profile# Go settingexport GOROOT=/usr/local/go export GOPATH=~/golib:~/goprojectexport 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

转载地址:http://vfvli.baihongyu.com/

你可能感兴趣的文章