当前位置:网站首页>Golang must know the Go Mod command
Golang must know the Go Mod command
2022-07-31 21:35:00 【m0_67401228】
Golang must know Go Mod commands
Golang is easy to learn
Article Directory
I. What is go mod?
Go modules are officially defined as:
A module is a collection of related Go packages.Modules are the unit of source code exchange and version control.
The go command directly supports the use of modules, including logging and resolving dependencies on other modules.modules replace the old GOPATH-based method of specifying which source files to use in a given build.
Second, detailed commands
1.init
Code:
go mod init
Generate a go.mod file. This command will initialize and create a new go.mod file in the current directory. Manually creating a go.mod file and including some module declarations is also equivalent to this command, and the go mod init command isHelp us make it easy, you can help us create it automatically.
2.download
Code:
go mod download
Download all dependencies specified in the go.mod file. Use this command to download the specified module. The format of the module can be specified according to the form of the main module dependency or the form of [email protected]
3.tidy
Code:
go mod tidy
Organize existing dependencies, use this command to download the specified module, and delete the modules that are no longer used
4.graph
Code:
go mod graph
View the existing dependency structure and generate a report of all dependencies of the project, but the readability is too poor, and the graphics are more convenient.
5.edit
Code:
go mod edit
Edit the go.mod file, then download or edit it
5.vendor
Code:
go mod vendor
Export all dependencies of the project to the vendor directory, copy from the mod to the vendor directory of the project, the IDE can recognize such a directory.
5.verify
Code:
go mod verify
Check whether a module has been tampered with, and check whether a common module error has been tampered with
5.why
Code:
go mod why
Check why you need to depend on a module, and check whether an uncommon module is a reference of which module
Summary
Through the above, it is easy to understand how to use go mod in Golang.Go mod provides a series of commands for manipulating modules, and module support is now built into all go commands, not just go mod commands.For example, when using go get, dependency package versions are often automatically added, removed, upgraded, and downgraded in the background.
Hope this blog will be useful to you.I am the King of Light, and I speak for myself.
Let me introduce myself first. The editor graduated from Shanghai Jiaotong University in 2013. I worked in a small company and went to big factories such as Huawei and OPPO. I joined Alibaba in 2018, until now.I know that most junior and intermediate java engineers want to upgrade their skills, they often need to explore their own growth or sign up to study, but for training institutions, the tuition fee is nearly 10,000 yuan, which is really stressful.Self-learning that is not systematic is very inefficient and lengthy, and it is easy to hit the ceiling and the technology stops.Therefore, I collected a "full set of learning materials for java development" for everyone. The original intention is also very simple. I hope to help friends who want to learn by themselves but don't know where to start, and at the same time reduce everyone's burden.Add the business card below to get a full set of learning materials
边栏推荐
- 深度学习中的batch(batch size,full batch,mini batch, online learning)、iterations与epoch
- <artifactId>ojdbc8</artifactId>「建议收藏」
- Istio introduction
- 【AcWing】The 62nd Weekly Match 【2022.07.30】
- 顺序表的实现
- 架构实战营模块八作业
- spark reports an error OutOfMemory "recommended collection"
- PCB stackup design
- Several methods for deleting specified elements in Golang slices
- matplotlib ax bar color Set the color, transparency, label legend of the ax bar
猜你喜欢

GAC Honda Safety Experience Camp: "Danger" is the best teacher

MATLAB program design and application 2.4 Common internal functions of MATLAB

The old music player WinAmp released version 5.9 RC1: migrated to VS 2019, completely rebuilt, compatible with Win11

Realize serial port receiving data based on STM32 ring queue

Bika LIMS open source LIMS set - use of SENAITE (detection process)

第六章

Architect 04 - Application Service Encryption Design and Practice

idea中搜索具体的字符内容的快捷方式

【公开课预告】:超分辨率技术在视频画质增强领域的研究与应用

广汽本田安全体验营:“危险”是最好的老师
随机推荐
【核心概念】图像分类和目标检测中的正负样本划分以及架构理解
Memblaze发布首款基于长存颗粒的企业级SSD,背后有何新价值?
rj45对接头千兆(百兆以太网接口定义)
Poker Game in C# -- Introduction and Code Implementation of Blackjack Rules
Three.js入门
Commonly used security penetration testing tools (penetration testing tools)
使用 Flutter 和 Firebase 制作!计数器应用程序
[Code Hoof Set Novice Village 600 Questions] Leading to the combination of formulas and programs
Implementation of a sequence table
高效并发:Synchornized的锁优化详解
BM3 flips the nodes in the linked list in groups of k
How programmers learn open source projects, this article tells you
-xms -xmx(information value)
flowable workflow all business concepts
[Open class preview]: Research and application of super-resolution technology in the field of video image quality enhancement
A solution to the server encountered an internal error that prevented it from fulfilling this request [easy to understand]
How to debug TestCafe
Pytorch lstm time series prediction problem stepping on the pit "recommended collection"
移动web开发02
Getting Started with Tkinter