Skip to content

go-pin-versions

Dockerfilesuspiciousno fixdefault: offdockerfile/hadolint

Reports a go install or go get of a package without a version, or at latest or none (example.com/tool@latest). example.com/tool@v1.4.0 is pinned. A path that starts with . or / (a package of the current module) is not reported.

@latest builds whatever release is newest on the day of the build, so the tool in the image changes between builds and a new release can fail or behave differently. Without any version, go install uses the version in the go.mod of the working directory (and fails when there is none), and go get moves it to the latest release. In both cases the Dockerfile does not say which version ends up in the image.

Write the version: go install example.com/tool@v1.4.0.

Reported
...
RUN gem install --source https://rubygems.org rails:7.0
RUN gem install rails:7.0
RUN gem install rails -v 7.0
RUN go install example.com/x
RUN go install example.com/x@v1
RUN go install example.com/x@latest
dockerfile:
lint:
rules:
go-pin-versions: warn # off (default), warn, error

Enabled by the presets: dockerfile/hadolint.

Suppress one line with sudsy-disable-next-line go-pin-versions in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
hadolint DL3062 partial go install and go get; go run is not checked.