go开发环境配置(VS code)

一、下载.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
  • 4
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值