I 'd like to pin the version of one package, so whenever I run
go get -u ./...
..this package would stay unchanged (but the rest refreshed normally).
Use go modules. It was specifically designed to handle precise version control.
In your package's go.mod
you can pin any dependencies to a fixed version e.g.
module example.com/hello
go 1.12
require (
golang.org/x/text v0.3.0 // indirect
rsc.io/quote v1.5.2
rsc.io/quote/v3 v3.0.0
rsc.io/sampler v1.3.1 // indirect
)
You can update individual package versions e.g.:
go get rsc.io/quote/v3@master
Will pull the latest commit version (beyond even any semver tagged version).
You can also hand edit go.mod
for extra precision.
P.S. you need go version 1.11 or later for go modules. go 1.13 has modules turned on by default. Earlier versions you have to explicitly enable it via the env var GO111MODULE=ON
.