Documentation
¶
Overview ¶
Package version resolves the version string a binary reports.
There are two ways a build gets one, and a binary has to handle both:
- A release build passes it explicitly, with -ldflags="-X main.version=1.46.0". This is what the Dockerfiles do, and it is the only way to get the exact tag being released.
- `go install module/cmd/x@v1.46.0` passes no ldflags at all, but the Go toolchain embeds the module version it resolved, which Resolve reads back. Without this a go-installed binary reports "dev" and gives its user no way to tell what they are running.
A plain `go build` from a working tree gets no ldflags either, but the toolchain stamps a version derived from VCS — "v1.46.0+dirty" for a tree with uncommitted changes — which is more use than a placeholder, so it is reported as-is. Only when there is no version to derive, as with -buildvcs=false or outside a repository, does the toolchain report "(devel)"; that is not a version and the placeholder stands instead.
Verified against all four paths: ldflags wins; `go install ...@v1.46.0` reports v1.46.0; `go build` reports v1.46.0+dirty; `go build -buildvcs=false` reports the placeholder.
Index ¶
Constants ¶
const Placeholder = "dev"
Placeholder is what a main package's version variable holds until a build overrides it. Resolve treats it as "nothing was passed".
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.