当前位置:网站首页>[go] go mod mode, package 12import/add is not in goroot
[go] go mod mode, package 12import/add is not in goroot
2022-06-22 23:46:00 【weixin_ forty-three million two hundred and twenty-four thousan】
Compile or run go Engineering Times should be wrong , First look at the environment variables go env see GO111MODULE What is the status .
There are two cases to deal with
1, The project is mod Pattern
a) If GO111MODULE=on, Let's see if there is go.mod file , If not go mod init once
When it's done go mod tidy that will do ;
b) If GO111MODULE=on, And there are go.mod, directly go mod tidy;
c) If GO111MODULE=off, The open mod Pattern export GO111MODULE="on", Then go on a)
d) There's another situation , Local go mod If you want to manually transfer the project to linux Compile and run on , If you put go.mod The documents are sent directly to , Will also report this error , The right thing to do is Linux Create a new project under the directory and execute go mod init , Then all documents of the local project, including go.mod Pass it on and then build, It's normal at this time
2, Project not opened mod Pattern
At this time, the default is from $GOPATH Next scan , If it's in linux Compile or run , Then close GO111MODULE:
export GO111MODULE="off"
source /etc/profile
After closing, you can go env Check again to see if it works ;
If it's in goland Next , Then remove the button -->ok --> Click in the blank space of the mouse to be normal :

边栏推荐
- 1. class inheritance (point)
- [STM32 skill] use the hardware I2C of STM32 Hal library to drive rx8025t real-time clock chip
- Express、路由(Route)、Request对象、Response对象、中间件、EJS模板
- MySQL master-slave synchronization and its basic process of database and table division
- 【PHP】php多态
- 2. interface (calculator)
- xml转义字符对照表
- Longest word in output string
- Flutter outsourcing, undertaking flutter project
- three.js模拟驾驶游览艺术展厅---打造超级相机控制器
猜你喜欢

xml转义字符对照表

three.js模拟驾驶游览艺术展厅---打造超级相机控制器

事物系统的几种异常场景

Common operations of sourcetree version management

MySQL8.0轻松完成GTID主从复制

Smart data won two annual awards at the second isig China Industrial Intelligence Conference

Digital data depth | about software self-control, source code left, no code right

KunlunDB查询优化(二)Project和Filter下推

Redis缓存

C language greedy snake
随机推荐
Various schemes for lazy loading of pictures
Longest word in output string
剑指 Offer 05. 替换空格
软件构造课程ADT与OOP理解
Dip1000,1 of D
KunlunDB 查询优化(一)
js图片分辨率压缩
Unity:利用 射线Ray 检测物体
事物系统的几种异常场景
js----SVG转PNG
OJ每日一练——整理命名
阻止别人使用浏览器调试
OJ每日一练——跨越2020
14. longest common prefix
xml转义字符对照表
node-fetch下载文件
SOA Service Oriented Architecture
IPV4的未来替代品!一文读懂IPV6的优势特点和地址类型
Unity: use ray to detect objects
剑指 Offer 06. 从尾到头打印链表