一、下载.msi安装文件,自动配置环境变量
All releases - The Go Programming Language (google.cn)
二、创建main.go文件
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
三、插件安装失败问题处理:
在终端执行以下命令
go env -w GO111MODULE=on
go env -w GOPROXY=https://proxy.golang.com.cn,direct
重启VS Code,打开一个go文件,右下角出现提示,点击install all,【输出】展示日志:
Tools environment: GOPATH=E:\app\go
Installing 8 tools at E:\app\go\bin in module mode.
gotests
gomodifytags
impl
goplay
dlv
staticcheck
gopls
go-outline
Installing github.com/cweill/gotests/gotests@v1.6.0 (E:\app\go\bin\gotests.exe) SUCCEEDED
Installing github.com/cweill/gotests/gotests@v1.6.0 (E:\app\go\bin\gotests.exe) SUCCEEDED
Installing github.com/fatih/gomodifytags@v1.16.0 (E:\app\go\bin\gomodifytags.exe) SUCCEEDED
Installing github.com/fatih/gomodifytags@v1.16.0 (E:\app\go\bin\gomodifytags.exe) SUCCEEDED
Installing github.com/josharian/impl@v1.1.0 (E:\app\go\bin\impl.exe) SUCCEEDED
Installing github.com/josharian/impl@v1.1.0 (E:\app\go\bin\impl.exe) SUCCEEDED
Installing github.com/haya14busa/goplay/cmd/goplay@v1.0.0 (E:\app\go\bin\goplay.exe) SUCCEEDED
Installing github.com/haya14busa/goplay/cmd/goplay@v1.0.0 (E:\app\go\bin\goplay.exe) SUCCEEDED
Installing github.com/go-delve/delve/cmd/dlv@latest (E:\app\go\bin\dlv.exe) SUCCEEDED
Installing github.com/go-delve/delve/cmd/dlv@latest (E:\app\go\bin\dlv.exe) SUCCEEDED
Installing honnef.co/go/tools/cmd/staticcheck@latest (E:\app\go\bin\staticcheck.exe) SUCCEEDED
Installing honnef.co/go/tools/cmd/staticcheck@latest (E:\app\go\bin\staticcheck.exe) SUCCEEDED
Installing golang.org/x/tools/gopls@latest (E:\app\go\bin\gopls.exe) SUCCEEDED
All tools successfully installed. You are ready to Go. :)
Installing golang.org/x/tools/gopls@latest (E:\app\go\bin\gopls.exe) SUCCEEDED
Installing github.com/ramya-rao-a/go-outline@v0.0.0-20210608161538-9736a4bde949 (E:\app\go\bin\go-outline.exe) SUCCEEDED
All tools successfully installed. You are ready to Go. :)
附录一
2024/4/23
# go版本信息
E:\>go version
go version go1.21.0 windows/amd64
VS Code版本信息:
版本: 1.71.0 (system setup)
日期: 2022-09-01T07:36:10.600Z
Electron: 19.0.12
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Windows_NT x64 10.0.19042
沙盒化: No