当前位置:网站首页>【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开发全套学习资料》送给大家,初衷也很简单,就是希望帮助到想自学又不知道该从何学起的朋友,同时减轻大家的负担。添加下方名片,即可获取全套学习资料哦
边栏推荐
- Difficulty comparison between high concurrency and multithreading (easy to confuse)
- 接口报错no message avaliable
- Exam Questions Previous True Questions Wrong Bills [The Fourth Session] [Provincial Competition] [Group B]
- 2.(1)栈的链式存储、链栈的操作(图解、注释、代码)
- 那些破釜沉舟入局Web3.0的互联网精英都怎么样了?
- 基本正则表达式元字符,字符,次数,锚定分组
- Basic usage of Koa framework
- nohup原理
- 如何在uni-app中选择一个合适的UI组件库
- Chapter 16: Constructing the Magic Square for Prime Numbers of Order n(5,7)
猜你喜欢
DHCP原理与配置
银河麒麟高级服务器v10 sp1 手动加载Raid卡驱动
How to use repeating-linear-gradient
Log4net 思维导图
文件 - 05 下载文件:根据文件Id下载文件
Difficulty comparison between high concurrency and multithreading (easy to confuse)
小实战项目之——吃货联盟订餐系统
Core Tower Electronics won the championship in the Wuhu Division of the 11th China Innovation and Entrepreneurship Competition
讲解实例+详细介绍@Resource与@Autowired注解的区别(全网最全)
(border-box)盒子模型w3c、IE的区别
随机推荐
银河麒麟服务器v10 sp1安装.net6
LeetCode刷题——摆动序列#376#Medium
Database Principles Homework 2 — JMU
第三方库-store
Obtaining server and client information
SQLite数据库连接字符串
codec2 BlockPool:不可读库
高并发与多线程之间的难点对比(容易混淆)
Postgresql source code learning (33) - transaction log ⑨ - see the overall process of log writing from the insert record
Analysis of the principle and implementation of waterfall flow layout
【C语言项目合集】这十个入门必备练手项目,让C语言对你来说不再难学!
MySQL笔记下
Zero-Shot Learning & Domain-aware Visual Bias Eliminating for Generalized Zero-Shot Learning
2022.7.29 数组
mysql索引失效的常见9种原因详解
文件 - 03 下载文件:根据文件id获取下载链接
Web浏览器工作流程解析
那些破釜沉舟入局Web3.0的互联网精英都怎么样了?
Bulk free text translation
Dart入门