当前位置:网站首页>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
边栏推荐
- 使用 Flutter 和 Firebase 制作!计数器应用程序
- BM3 将链表中的节点每k个一组翻转
- Realization of character makeup
- Batch (batch size, full batch, mini batch, online learning), iterations and epochs in deep learning
- leetcode 665. Non-decreasing Array
- 架构实战营模块八作业
- ReentrantLock原理(未完待续)
- Given an ip address, how does the subnet mask calculate the network number (how to get the ip address and subnet mask)
- grep command written test questions
- 【Yugong Series】July 2022 Go Teaching Course 023-List of Go Containers
猜你喜欢
如何才能真正的提高自己,成为一名出色的架构师?
iNeuOS industrial Internet operating system, equipment operation and maintenance business and "low-code" form development tools
OSPFv3的基本配置
How to identify fake reptiles?
Efficient Concurrency: A Detailed Explanation of Synchornized's Lock Optimization
PCB stackup design
Poker Game in C# -- Introduction and Code Implementation of Blackjack Rules
1161. Maximum Sum of Elements in Layer: Hierarchical Traversal Application Problems
基于STM32 环形队列来实现串口接收数据
请问我的这段sql中sql语法哪里出了错
随机推荐
利用反射实现一个管理对象信息的简单框架
BM3 将链表中的节点每k个一组翻转
leetcode 665. Non-decreasing Array
第六章
Basic Grammar Introduction of Carbon Tutorial (Tutorial)
架构实战营模块八作业
1161. Maximum Sum of Elements in Layer: Hierarchical Traversal Application Problems
MATLAB program design and application 2.4 Common internal functions of MATLAB
【论文精读】iNeRF
Douyin fetches video list based on keywords API
Talking about the algorithm security of network security
广汽本田安全体验营:“危险”是最好的老师
如何才能真正的提高自己,成为一名出色的架构师?
renderjs usage in uni-app
Memblaze发布首款基于长存颗粒的企业级SSD,背后有何新价值?
Embedded development has no passion, is it normal?
Go mode tidy reports an error go warning “all” matched no packages
Redis综述篇:与面试官彻夜长谈Redis缓存、持久化、淘汰机制、哨兵、集群底层原理!...
嵌入式开发没有激情了,正常吗?
A shortcut to search for specific character content in idea