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

14 lines
658 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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。