ubuntu golang vscode environment to build

Installation golang

# 到官网下载二进制包https://golang.org/dl/ 或者 https://studygolang.com/dl
 
 
# 解压包
tar -xvf go1.12.9.linux-amd64.tar.gz
 
 
# 移动到正常目录下
sudo mv go /usr/local/
 
 
# 添加环境变量, 配置代理, 启用gomod
sudo vim /etc/profile.d/golang.sh
export PATH=$PATH:/usr/local/go/bin
export GO111MODULE=on
export GOPROXY=https://goproxy.io
 
 
# 加载环境变量
source /etc/profile.d/golang.sh
 
 
# 测试安装
go version

Installation vscode

To the official website to download VSCode https://code.visualstudio.com/
download the deb package, double-click the installation or can be installed dpkg -i

Vscode installation of plug-ins go

Installing additional analytical tool



If the walls could not because of the installation, over the wall, or manually install
https://github.com/Microsoft/vscode-go/wiki/Go-tools-that-the-Go-extension-depends-on
installation log
Installing github. COM / mdempsky / gocode the SUCCEEDED
the Installing the SUCCEEDED github.com/uudashr/gopkgs/cmd/gopkgs
the Installing the SUCCEEDED github.com/ramya-rao-a/go-outline
the Installing the SUCCEEDED github.com/acroca/go-symbols
the Installing golang.org/ X / Tools / cmd / Guru the SUCCEEDED
the Installing the SUCCEEDED golang.org/x/tools/cmd/gorename
the Installing the SUCCEEDED github.com/go-delve/delve/cmd/dlv
the Installing the SUCCEEDED github.com/stamblerre/gocode
the Installing github.com/ rogpeppe / godef SUCCEEDED
Installing github.com/sqs/goreturns SUCCEEDED
Installing golang.org/x/lint/golint SUCCEEDED
Installing github.com/cweill/gotests/... SUCCEEDED
Installing github.com/fatih/gomodifytags SUCCEEDED
Installing github.com/josharian/impl SUCCEEDED
Installing github.com/davidrjenni/reftools/cmd/fillstruct SUCCEEDED
Installing github.com/haya14busa/goplay/cmd/goplay SUCCEEDED
Installing github.com/godoctor/godoctor SUCCEEDED

Configuration vscode

{
    "files.autoSave": "afterDelay",
    "go.buildOnSave": "workspace",
    "go.lintOnSave": "package",
    "go.vetOnSave": "package",
    "go.formatTool": "goreturns",
    "go.goroot": "/usr/local/go",
    "go.useLanguageServer": true,
    "go.alternateTools": {
      "go-langserver": "gopls",
    },
    "go.languageServerExperimentalFeatures": {
      "format": true,
      "autoComplete": true
    },
    "[go]": {
        "editor.codeActionsOnSave": {
            "source.organizeImports": true
        },
    }
}

Guess you like

Origin www.cnblogs.com/billxing/p/11422174.html