VSCode安装go插件失败

VSCode安装go插件失败,第1张

问题1:VSCode安装go插件失败 解决方法: (1)配置环境变量
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.io,direct

打开vsCode终端,依次执行上边两条命令

(2)重启软件安装

重启软件,创建一个go程序执行,会提示“install all”,点击开始安装

package main

import "fmt"

func main() {
    fmt.Println("Hello world")
}

(3)安装结束如下图


问题2:运行调试go程序失败

提示:go: go.mod file not found in current directory or any parent directory; see ‘go help modules’
exit status 1

解决方法:

在vsCode终端运行下边命令

go env -w GO111MODULE=auto

调试成功效果图:

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/994296.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存