当前位置:网站首页>【Go报错】go go.mod file not found in current directory or any parent directory 错误解决
【Go报错】go go.mod file not found in current directory or any parent directory 错误解决
2022-07-31 05:50:00 【饿饿好饿】
场景:
安装好 liteide 之后创建了第一个 “hello world” 的golang 项目,却报了如下错误。
问题描述:

报错:
D:/golang/bin/go.exe build [C:/Users/dell/go/src/hello]
go: go.mod file not found in current directory or any parent directory; see 'go help modules'
错误: 进程退出代码 1.
原因分析:
go 的环境配置问题。与 golang 的包管理有关。
解决方案:
如果你是 Windows 系统,快捷键 “Win+R”,输入cmd,打开终端。输入:
go env -w GO111MODULE=auto
解释:
GO111MODULE 是 Go 1.11 引入的新版模块管理方式。
GO111MODULE 环境变量用于开启或关闭 Go 语言中的模块支持,它有 off、on、auto 三个可选值,默认为 auto。
GO111MODULE=off
无模块支持,go 会从 $GOPATH 文件夹和 vendor 目录中寻找依赖项。GO111MODULE=on
模块支持,go 忽略 $GOPATH 文件夹,只根据 go.mod 下载依赖。GO111MODULE=auto
在 $GOPATH/src 外层且根目录有 go.mod 文件时,开启模块支持;否者无模块支持。
参考链接
先自我介绍一下,小编13年上师交大毕业,曾经在小公司待过,去过华为OPPO等大厂,18年进入阿里,直到现在。深知大多数初中级java工程师,想要升技能,往往是需要自己摸索成长或是报班学习,但对于培训机构动则近万元的学费,着实压力不小。自己不成体系的自学效率很低又漫长,而且容易碰到天花板技术停止不前。因此我收集了一份《java开发全套学习资料》送给大家,初衷也很简单,就是希望帮助到想自学又不知道该从何学起的朋友,同时减轻大家的负担。添加下方名片,即可获取全套学习资料哦
边栏推荐
- 熟悉而陌生的新朋友——IAsyncDisposable
- SQL Server Datetime2数据类型
- 03-SDRAM:写操作(突发)
- Analysis of the implementation principle and detailed knowledge of v-model syntactic sugar and how to make the components you develop support v-model
- Database Principles Homework 3 — JMU
- 2. (1) Chained storage of stack, operation of chain stack (illustration, comment, code)
- 文件 - 07 删除文件: 根据fileIds批量删除文件及文件信息
- 在 ASP.NET Core 应用程序启动时运行代码的 3 种方法
- How to choose a suitable UI component library in uni-app
- 项目练习——备忘录(增删改查)
猜你喜欢

拓扑排序的两种方法 --- dfs+Kahn

Run the NPM will pop up to ask "how are you going to open this file?"

DHCP原理与配置

2.(1)栈的链式存储、链栈的操作(图解、注释、代码)

服务器硬件及RAID配置实战

【C语言项目合集】这十个入门必备练手项目,让C语言对你来说不再难学!

那些破釜沉舟入局Web3.0的互联网精英都怎么样了?

浅析伪类和伪元素

Core Tower Electronics won the championship in the Wuhu Division of the 11th China Innovation and Entrepreneurship Competition

Postgresql source code learning (34) - transaction log ⑩ - full page write mechanism
随机推荐
【C语言项目合集】这十个入门必备练手项目,让C语言对你来说不再难学!
浅析重复线性渐变repeating-linear-gradient如何使用
数据库概论 - MySQL的简单介绍
Zotero | Zotero translator plugin update | Solve the problem that Baidu academic literature cannot be obtained
DHCP原理与配置
Oracle 日期函数相关
常用命令讲解
03-SDRAM:写操作(突发)
LeetCode brush # 376 # Medium - swing sequence
第三方库-store
那些破釜沉舟入局Web3.0的互联网精英都怎么样了?
关于求反三角函数的三角函数值
Analysis of the implementation principle and detailed knowledge of v-model syntactic sugar and how to make the components you develop support v-model
讲解实例+详细介绍@Resource与@Autowired注解的区别(全网最全)
Kubernetes scheduling
自动翻译软件-批量批量自动翻译软件推荐
服务器和客户端信息的获取
cp 的用法
tidyverse笔记——管道函数
试题 历届真题 错误票据【第四届】【省赛】【B组】