Documentation
¶
Overview ¶
Package buildinfo reports what build this binary is, for `idea version`, the daemon's /api/v1/version endpoint and `idea doctor`.
Before this existed the only answer was a hardcoded const in the daemon, so every install said "0.1.0" and a bug report could not name a build.
Three build paths produce three different amounts of information, and the stamp says which one it got rather than inventing the rest:
- `make build` / a release build: -ldflags -X sets Version and Commit.
- `go install ./cmd/idea` from a checkout: nothing is stamped, but the Go toolchain records vcs.revision and vcs.modified, so the commit is known and a dirty tree is reported as such.
- `go install <module>@<version>` from the proxy: the module version is known (debug.BuildInfo.Main.Version); there is no VCS data at all, because the proxy serves an extracted zip with no .git. That absence is what distinguishes this path — Main.Version is also set for a local build, to a pseudo-version naming a release that does not exist.
An explicit -ldflags stamp wins over the toolchain's, and not only because it is more specific: building inside a git worktree, the toolchain reports the *main* checkout's HEAD rather than the worktree's, so `make build` (which takes the commit from `git rev-parse` in the working directory) is the one that names the commit you actually built.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Info ¶
type Info struct {
// Version is a release version ("v0.1.0"), a module version from the proxy,
// or "dev" when neither is known.
Version string `json:"version"`
// Commit is the VCS revision when it is known, "" otherwise.
Commit string `json:"commit,omitempty"`
// Modified reports a build made from a dirty working tree.
Modified bool `json:"modified,omitempty"`
}
Info describes the running build.