1package version
 2
 3import "runtime/debug"
 4
 5// Build-time parameters set via -ldflags
 6
 7var Version = "devel"
 8
 9// A user may install crush using `go install github.com/charmbracelet/crush@latest`.
10// without -ldflags, in which case the version above is unset. As a workaround
11// we use the embedded build version that *is* set when using `go install` (and
12// is only set for `go install` and not for `go build`).
13func init() {
14	info, ok := debug.ReadBuildInfo()
15	if !ok {
16		return
17	}
18	mainVersion := info.Main.Version
19	if mainVersion != "" && mainVersion != "(devel)" {
20		Version = mainVersion
21	}
22}