ubuntu golang vscode环境搭建
安装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 安装vscode 到官网下载vscode https://code.visualstudio.com/下载deb包双击安装或者dpkg -i 安装即可 安装vscode 的go插件 安装其他工具 如果因为墙原因无法安装,请翻墙,或者手动安装https://github.com/Microsoft/vscode-go/wiki/Go-tools-that-the-Go-extension-depends-on安装日志Installing github.com/mdempsky/gocode SUCCEEDEDInstalling github.com/uudashr/gopkgs/cmd/gopkgs SUCCEEDEDInstalling github.com/ramya-rao-a/go-outline SUCCEEDEDInstalling github.com/acroca/go-symbols SUCCEEDEDInstalling golang.org/x/tools/cmd/guru SUCCEEDEDInstalling golang.org/x/tools/cmd/gorename SUCCEEDEDInstalling github.com/go-delve/delve/cmd/dlv SUCCEEDEDInstalling github.com/stamblerre/gocode SUCCEEDEDInstalling github.com/rogpeppe/godef SUCCEEDEDInstalling github.com/sqs/goreturns SUCCEEDEDInstalling golang.org/x/lint/golint SUCCEEDEDInstalling github.com/cweill/gotests/... SUCCEEDEDInstalling github.com/fatih/gomodifytags SUCCEEDEDInstalling github.com/josharian/impl SUCCEEDEDInstalling github.com/davidrjenni/reftools/cmd/fillstruct SUCCEEDEDInstalling github.com/haya14busa/goplay/cmd/goplay SUCCEEDEDInstalling github.com/godoctor/godoctor SUCCEEDED 配置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 }, } }