Linux command
go-mod 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Initialize new module
go mod init [module-name]
Download dependencies
go mod download
Tidy dependencies
go mod tidy
Vendor dependencies
go mod vendor
Verify checksums
go mod verify
说明
go mod manages Go modules, the official dependency management system for Go. Modules are collections of packages with versioned dependencies defined in go.mod files. The command initializes modules, manages dependencies, and maintains reproducible builds. It integrates with module proxies and checksum databases to ensure package integrity and availability.
参数
- init _NAME_
- Initialize new module.
- download
- Download modules to cache.
- tidy
- Add missing, remove unused.
- vendor
- Create vendor directory.
- verify
- Verify dependencies.
- graph
- Print dependency graph.
- why _PACKAGE_
- Explain why needed.
- --help
- Display help information.
FAQ
What is the go-mod command used for?
go mod manages Go modules, the official dependency management system for Go. Modules are collections of packages with versioned dependencies defined in go.mod files. The command initializes modules, manages dependencies, and maintains reproducible builds. It integrates with module proxies and checksum databases to ensure package integrity and availability.
How do I run a basic go-mod example?
Run `go mod init [module-name]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does init _NAME_ do in go-mod?
Initialize new module.