解决go: go.mod file not found in current directory or any parent directory; see ‘go help modules‘_林猛男的博客-CSDN博客_go mod not found


本站和网页 https://blog.csdn.net/longgeaisisi/article/details/121288696 的作者无关,不对其内容负责。快照谨为网络故障时之索引,不代表被搜索网站的即时页面。

解决go: go.mod file not found in current directory or any parent directory; see ‘go help modules‘_林猛男的博客-CSDN博客_go mod not found
解决go: go.mod file not found in current directory or any parent directory; see ‘go help modules‘
林猛男
已于 2022-04-03 23:16:42 修改
55321
收藏
88
分类专栏:
【22】问题解决
文章标签:
golang
于 2021-11-12 15:30:46 首次发布
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/longgeaisisi/article/details/121288696
版权
【22】问题解决
专栏收录该内容
5 篇文章
0 订阅
订阅专栏
一、问题:当go get的时候报错如下(或者golang的版本升级之后报错如下)
go: go.mod file not found in current directory or any parent directory; see 'go help modules'
二、解决办法
1:开启go modules功能,命令行输入
go env -w GO111MODULE=on
2:在该项目目录下,初始化Go moudle,运行下面命令
go mod init xxx //xxx代表文件夹名
三、一些相关解释
go module介绍
go module是go官方自带的go依赖管理库,在1.13版本正式推荐使用go module可以将某个项目(文件夹)下的所有依赖整理成一个 go.mod 文件,里面写入了依赖的版本等 使用go module之后我们可不用将代码放置在src下使用 go module 管理依赖后会在项目根目录下生成两个文件 go.mod(会记录当前项目的所依赖)和go.sum(记录每个依赖库的版本和哈希值)
GO111MODULE GO111MODULE是 go modules 功能的开关
GO111MODULE=off,无模块支持,go命令行将不会支持module功能,寻找依赖包的方式将会沿用旧版本那种通过vendor目录或者GOPATH模式来查找。GO111MODULE=on,模块支持,go命令行会使用modules,而一点也不会去GOPATH目录下查找。GO111MODULE=auto,默认值,go命令行将会根据当前目录来决定是否启用module功能。这种情况下可以分为两种情形: (1)当前目录在GOPATH/src之外且该目录包含go.mod文件,开启模块支持。 (2)当前文件在包含go.mod文件的目录下面。
四、Go mod使用方法
//初始化模块:
Go mod init <项目模块名称>
//依赖关系处理,根据go.mod文件
Go mod tidy
//将依赖包复制到项目的vendor目录
Go mod vendor
//显示依赖关系
Go list -m all
//显示详细依赖关系
Go list -m -json all
//下载依赖
Go mod download [path@version]
参考来自:https://blog.csdn.net/weixin_40179091/article/details/117163598、https://www.cnblogs.com/l199616j/p/15269281.html
林猛男
关注
关注
35
点赞
88
收藏
打赏
评论
解决go: go.mod file not found in current directory or any parent directory; see ‘go help modules‘
一、问题:当go build的时候报错如下(或者golang的版本从1.6升级到1.16之后报错如下)go: go.mod file not found in current directory or any parent directory; see 'go help modules'二、解决办法(选其中一种即可)办法1:命令行输入go env -w GO111MODULE=auto办法2:初始化Go moudle,在目录下运行下面命令go mod init XXX //xxx代表文件夹名
复制链接
扫一扫
专栏目录
Shopify
03-18
Shopify
Go语言分包编程
最新发布
mockery_B的博客
11-25
147
G语言多包编程出错 go: go.mod file not found in current directory or any parent directory; see 'go help modules'
评论 5
您还未登录,请先
登录
后发表或查看评论
解决vscode 报错 go: go.mod file not found in current directory
qq_36936510的博客
05-29
9921
解决方案:
go env -w GO111MODULE=off
Go环境异常问题go: go.mod file not found in current directory or any parent directory; see ‘go help modules
青山师
09-24
2478
高版本go(1.17)执行时错误: go: go.mod file not found in current directory or any parent directory; see ‘go help modules’…
解决:参考链接:
https://blog.golang.org/go116-module-changes
再1.16进行了module变更。
所以高版本需要设置一下 :
go env -w GO111MODULE=auto
再次运行程序即可。
...
Go学习笔记-语言基础, go.mod file not found in current directory or any parent directory
wwj256的专栏
10-31
73
fmt.Printf(“cc=%s,cc=%T”,cc,cc)//cc=abcd,cc=string" title=“” data-bs-original-title=“复制” aria-label=“复制”>fmt.Println(“cc=”,cc,“dd=”,dd)" title=“” data-bs-original-title=“复制” aria-label=“复制”>}" title=“” data-bs-original-title=“复制” aria-label=“复制”>
go mod初探及踩坑(GO11包管理工具)
kevinh531的博客
03-20
4万+
1、go mod是什么
go mod 是Golang 1.11 版本引入的官方包(package)依赖管理工具,用于解决之前没有地方记录依赖包具体版本的问题,方便依赖包的管理。
之前Golang 主要依靠vendor和GOPATH来管理依赖库,vendor相对主流,但现在官方更提倡go mod。
2、go mod初始化及使用
Golang 提供一个环境变量GO111MODULE 来设置是...
我的Go+语言初体验——Go+安装踩坑
夕目
11-29
671
环境
Windows10
Go+是什么
用于工程、STEM 教育和数据科学的 Go+ 语言
Go+的优势
Go+对于科学数据:
Go+ 提供了更强大的数学表达式功能,例如有理数表达式,可简化数据
科学目的的编程。
Go+ 支持字节码后端和 Go 代码生成。
与 Python 相比,Go+ 提供:
更好的性能
更像自然语言的语法
与 Python 生态系统的兼容性(未来)
数据科学和工程的相同语言
完全兼容go语法
windows下安装go环境
进入go的下载页
我这里下载的是 zip 文件
关于学习go中遇到的 go.mod file not found in current directory or any parent directory; see ‘go help modules‘
南风未闻的博客
11-26
1426
go学习日常碰到的问题
问题描述:
今天在学习是导入项目时出现go.mod file not found in current directory or any parent directory; see ‘go help modules’
原因分析:
一种情况就是我的 go module未开启
解决方案:
开启go module操作,输入go env 将其开启,然后对其进行初始化操作:
go mod init xxx这里是你要添加的mod的文件夹名字
成功创建mod,后面就可以运行项目啦。
【Go报错】go go.mod file not found in current directory or any parent directory 错误解决
m0_67401417的博客
07-31
1万+
安装好liteide之后创建了第一个“helloworld”的golang项目,却报了如下错误。
go踩坑——no required module provides package : go.mod file not found in current directory or any parent
一蓑烟雨任平生
07-03
6876
报错:no required module provides package : go.mod file not found in current directory or any parent directory;
go: go.mod file not found in current directory or any parent directory
CamphorBlossom的博客
12-04
3964
昨天本想复习一下go,所以特地将golang从1.15升级到最新的1.17.3版本,哪知运行带有导入第三方包的文件就报红(内置模块没有问题)。
go.mod file是什么东东?为此上网查阅了一番。
Go最初推出来的时候并没有一个库管理方式,而是采用GOPATH的方式。
go module介绍 (官方文档)
go module是go官方自带的go依赖管理库,在1.13版本正式推荐使用。
go module可以将某个项目(文件夹)下的所有依赖整理成一个 go.mod 文件,里面写入了依...
go: go.mod file not found in current directory or any parent directory; 解决方法
weixin_43816121的博客
09-02
218
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 错误解决
weixin_44211968的博客
06-07
1万+
go: go.mod file not found in current directory or any parent directory 错误解决
go: go.mod file not found in current directory or any parent directory; see ‘go help modules‘
聪明不喝牛奶的博客
09-15
1608
问题描述
今天开始接触新的语言-Go语言,但是在起步的时候总是碰壁!!!就在跑程序的时候就给我报了一个这个!!
go: go.mod file not found in current directory or any parent directory; see ‘go help modules‘
弄的我真的很头大!!!所以我查阅别的博主的优秀文章之后,做出下面的解决办法!
解决问题
第一步:首先先检查一下的go 生产环境是不是正确的
go env
发现gomodule是空的,那么这个就使我们的够环境
Golang:go: go.mod file not found in current directory or any parent directory; see ‘go help modules‘
热门推荐
李白
05-22
4万+
golang的版本从1.6升级到1.16之后,go test就报错如下:
go module介绍
go module是go官方自带的go依赖管理库,在1.13版本正式推荐使用
go module可以将某个项目(文件夹)下的所有依赖整理成一个 go.mod 文件,里面写入了依赖的版本等
使用go module之后我们可不用将代码放置在src下了
使用 go module 管理依赖后会在项目根目录下生成两个文件 go.mod 和 go.sum。
go.mod 中会记录当前项目的所依赖,文件格式如
GO mod 遇到 not found: unrecognized version
qq_20239111的博客
04-25
595
解决方法
go env -w GOPRIVATE=github.com
go.mod file not found in current directory or any parent directory; see ‘go help modules‘
Laity
08-02
8048
大家好,我是J哥
上面的情况是go的环境设置问题,执行
go env -w GO111MODULE=auto
关于golang第三方包的引用报错:no required module provides package
weixin_44952092的博客
04-16
2万+
关于golang第三方包的引用报错:no required module provides package : go.mod file not found in current directory or any parent directory;
执行:go env -w GO111MODULE=auto
自己这样执行就好了,希望对您有帮助
windows环境下go build 报错 go: go.mod file not found in current directory or any parent directory
isoyy的博客
11-30
678
第一次写helloword时遇到的问题。
在命令行执行go build 准备编译 hello.go 时 提示报错
go: go.mod file not found in current directory or any parent directory; see 'go help modules'
解决:
没有详细看过go build 命令的详细介绍,理所应当的以为当使用go build 时会自动编译GOPATH目录下所有的.go文件。
但实际上当仅使用go build时意味着使用当前目录进.
go: go.mod file not found in current directory or any parent directory. ‘go get‘ is no longer suppo
qq_46695411的博客
07-11
1238
先运行这一行代码
再运行你的go get命令就好了。参考:https://blog.csdn.net/sepnineth/article/details/125153354
“相关推荐”对你有帮助么?
非常没帮助
没帮助
一般
有帮助
非常有帮助
提交
©️2022 CSDN
皮肤主题:技术黑板
设计师:CSDN官方博客
返回首页
林猛男
CSDN认证博客专家
CSDN认证企业博客
码龄6年
暂无认证
129
原创
3万+
周排名
13万+
总排名
152万+
访问
等级
7955
积分
162
粉丝
527
获赞
129
评论
1885
收藏
私信
关注
热门文章
阿里云服务器ping不通解决办法(云服务器搭建完环境访问不了ip解决办法)
83995
2>/dev/null和>/dev/null 2>&1和2>&1>/dev/null的区别
76925
CSS选取第几个标签元素:nth-child(n)、first-child、last-child
64416
apt-get: command not found解决方案
61504
Linux查看文件大小的几种方法(超全)
58476
分类专栏
【23】Go语言基础知识
4篇
【22】问题解决
5篇
【01】PHP
19篇
【22】docker
2篇
【02】ThinkPHP
9篇
【03】Laravel
1篇
【04】Linux&服务器
35篇
【05】Mysql
13篇
【06】Nginx
【07】Redis
1篇
【08】Git、SVN
5篇
【09】HTML&前端
6篇
【10】CSS
9篇
【11】JavaScript
16篇
【12】Oracle
【13】GoLang
【14】Python
【15】Vue.js
1篇
【16】Node.js
1篇
【17】Bootstrap
1篇
【18】APICloud
1篇
【19】Android
3篇
【20】微信小程序开发
2篇
【21】微信公众号开发
4篇
【99】直播
【100】开发工具
4篇
【993】视频剪辑
【994】摄影修图
【995】创业项目
【996】面试总结
【997】项目总结
【998】职业规划
【999】其他
最新评论
解决 zsh:command not found
jzyzqbx120sjd:
cat: .bash_profile: No such file or directory
解决 zsh:command not found
m0_73036477:
输入cat .bash_profile
不是二图内容怎么办呢,没有要复制的内容
OBS多路推流插件使用方法(超级详细,亲测可用)
xu9949:
什么微信小程序可以获得服务器地址?
OBS多路推流插件使用方法(超级详细,亲测可用)
xu9949:
什么微信小程序可以获得服务器地址?
mysql数据库中查看当前使用的数据库是哪个数据库?
h j rong:
status命令查看不了,报错。
您愿意向朋友推荐“博客详情页”吗?
强烈不推荐
不推荐
一般般
推荐
强烈推荐
提交
最新文章
【4】Go内建变量类型
【3】Go变量定义
解决Goland错误:$GOPATH/go.mod exists but should not
2022年9篇
2021年11篇
2020年20篇
2019年38篇
2018年26篇
2017年32篇
目录
目录
分类专栏
【23】Go语言基础知识
4篇
【22】问题解决
5篇
【01】PHP
19篇
【22】docker
2篇
【02】ThinkPHP
9篇
【03】Laravel
1篇
【04】Linux&服务器
35篇
【05】Mysql
13篇
【06】Nginx
【07】Redis
1篇
【08】Git、SVN
5篇
【09】HTML&前端
6篇
【10】CSS
9篇
【11】JavaScript
16篇
【12】Oracle
【13】GoLang
【14】Python
【15】Vue.js
1篇
【16】Node.js
1篇
【17】Bootstrap
1篇
【18】APICloud
1篇
【19】Android
3篇
【20】微信小程序开发
2篇
【21】微信公众号开发
4篇
【99】直播
【100】开发工具
4篇
【993】视频剪辑
【994】摄影修图
【995】创业项目
【996】面试总结
【997】项目总结
【998】职业规划
【999】其他
目录
评论 5
被折叠的 条评论
为什么被折叠?
到【灌水乐园】发言
查看更多评论
打赏作者
林猛男
你的鼓励将是我创作的最大动力
¥2
¥4
¥6
¥10
¥20
输入1-500的整数
余额支付
(余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付
您的余额不足,请更换扫码支付或充值
打赏作者
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额
抵扣说明:
1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。 2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。
余额充值