当前位置:网站首页>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
边栏推荐
- Architecture Battalion Module 8 Homework
- Basics of ResNet: Principles of Residual Blocks
- NVIDIA已经开始测试AD106和AD107 GPU核心的显卡产品
- 第六章
- [Open class preview]: Research and application of super-resolution technology in the field of video image quality enhancement
- 如何才能真正的提高自己,成为一名出色的架构师?
- 【公开课预告】:超分辨率技术在视频画质增强领域的研究与应用
- Architect 04 - Application Service Encryption Design and Practice
- linux view redis version command (linux view mysql version number)
- [Code Hoof Set Novice Village 600 Questions] Leading to the combination of formulas and programs
猜你喜欢
STM32 full series development firmware installation guide under Arduino framework
Apache EventMesh distributed event-driven multi-runtime
MATLAB program design and application 2.4 Common internal functions of MATLAB
第七章
ThreadLocal
高通cDSP简单编程例子(实现查询高通cDSP使用率、签名),RK3588 npu使用率查询
Three. Introduction to js
SiC MOSFET的短路特性及保护
Chapter Six
Go mode tidy reports an error go warning “all” matched no packages
随机推荐
求n以内的素数
20. Support vector machine - knowledge of mathematical principles
BM5 merge k sorted linked lists
[Code Hoof Set Novice Village 600 Questions] Leading to the combination of formulas and programs
【AcWing】第 62 场周赛 【2022.07.30】
【AcWing】The 62nd Weekly Match 【2022.07.30】
linux view redis version command (linux view mysql version number)
架构实战营模块 8 作业
第七章
Redis Overview: Talk to the interviewer all night long about Redis caching, persistence, elimination mechanism, sentinel, and the underlying principles of clusters!...
GateWay implements load balancing
leetcode 665. Non-decreasing Array
【公开课预告】:超分辨率技术在视频画质增强领域的研究与应用
利用反射实现一个管理对象信息的简单框架
focus on!Haitai Fangyuan joins the "Personal Information Protection Self-discipline Convention"
Getting Started with Tkinter
性能优化:记一次树的搜索接口优化思路
广汽本田安全体验营:“危险”是最好的老师
BM3 将链表中的节点每k个一组翻转
sqlite3 simple operation