阅读golang mod文档
This commit is contained in:
14
Golang/Golang Document.md
Normal file
14
Golang/Golang Document.md
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# Golang
|
||||||
|
## Get Started
|
||||||
|
### Enable dependency tracking
|
||||||
|
当代码对其他module中包含的package进行了import时,在自己的module中来管理依赖。
|
||||||
|
|
||||||
|
自己的module通过`go.mod`文件来定义,`go.mod`文件中会track项目所需要的依赖。
|
||||||
|
|
||||||
|
#### go mod init
|
||||||
|
`go mod init <module-name>`命令会创建一个`go.mod`文件,其中`<module-name>`会是module path。
|
||||||
|
|
||||||
|
在实际开发中,module name通常是source code被保存的repository location,例如,`uuid`module的module name为`github.com/google/uuid`。
|
||||||
|
|
||||||
|
#### go mod tidy
|
||||||
|
`go mod tidy`命令会根据import添加缺失的module并且移除未使用的module。
|
||||||
Reference in New Issue
Block a user