VSCode builds Go development environment

Blog

Environment variable

Environment variables under linux

  • GOROOT (installation directory), GOPATH (working directory), GOBIN (executable file directory), PATH (environment variable)
vi /etc/profile

# Go setting
export GOROOT=/usr/local/go 
export GOPATH=~/golib:~/goproject
export GOBIN=~/gobin 
export PATH=$PATH:$GOROOT/bin:$GOBIN

Configuration

  • launch.json is the configuration file used by vscode for debugging, such as specifying the debugging language environment, specifying the debugging type, and so on. Examples of content are as follows:
{
    "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 Download the module to the local cache, the cache path is $GOPATH/pkg/mod/cache

Guess you like

Origin blog.csdn.net/thebigdipperbdx/article/details/111996424