Home > Backend Development > Golang > How Can I Pin Go Module Dependencies to Specific Commits?

How Can I Pin Go Module Dependencies to Specific Commits?

DDD
Release: 2024-12-31 17:14:11
Original
278 people have browsed it

How Can I Pin Go Module Dependencies to Specific Commits?

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
Copy after login

Streamlined Approach: go get Command

However, a simplified method emerged:

go get github.com/someone/some_module@af044c0995fe
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template