【注意】最后更新于 March 12, 2019,文中内容可能已过时,请谨慎使用。
命令
go modules直接作为子命令集成在go中:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
go mod
Go mod provides access to operations on modules.
Note that support for modules is built into all the go commands,
not just 'go mod'. For example, day-to-day adding, removing, upgrading,
and downgrading of dependencies should be done using 'go get'.
See 'go help modules' for an overview of module functionality.
Usage:
go mod <command> [arguments]
The commands are:
download download modules to local cache
edit edit go.mod from tools or scripts
graph print module requirement graph
init initialize new module in current directory
tidy add missing and remove unused modules
vendor make vendored copy of dependencies
verify verify dependencies have expected content
why explain why packages or modules are needed
Use "go help mod <command>" for more information about a command.
|
理解
一个项目中由多个go package组成,这个项目被保存在一个代码库中(如git)。
也就是说这个代码库中有多个go的package,如https://github.com/grpc/grpc-go这个项目。
Go Modules将这些packages称作module,每个Go项目中会有一个go.mod文件描述module的元数据信息。
参考