Go Modules: Dependency Homing to Specific Commits
Go modules, introduced in version 1.11, automate dependency management. However, sometimes, accessing unreleased features requires referencing a specific commit in a module's repository.
Manually Setting Commit Dependencies
Initially, it was necessary to manually edit the go.mod file with the syntax:
require github.com/someone/some_module v0.0.0-20181121201909-af044c0995fe
Streamlined Approach: go get Command
However, a simplified method emerged:
go get github.com/someone/some_module@af044c0995fe
This command automatically updates the go.mod and go.sum files, pointing the dependency to the desired commit.
Further Information
Refer to the official Go wiki for more details: https://github.com/golang/go/wiki/Modules#how-to-upgrade-and-downgrade-dependencies
The above is the detailed content of How Can I Pin Go Module Dependencies to Specific Commits?. For more information, please follow other related articles on the PHP Chinese website!