Files
rikako-note/Golang/Golang Document.md
2025-01-05 21:23:10 +08:00

658 B
Raw Blame History

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例如uuidmodule的module name为github.com/google/uuid

go mod tidy

go mod tidy命令会根据import添加缺失的module并且移除未使用的module。