Some checks failed
CI pipeline for ffd-indexer / checks (go test + golangci) (push) Failing after 26s
CI pipeline for ffd-indexer / build binaries + containers (push) Failing after 3s
CI pipeline for ffd-indexer / format (gofmt + nixfmt) (push) Failing after 3s
CI pipeline for ffd-indexer / integration (live scrape + Typesense) (push) Failing after 20s
45 lines
1.3 KiB
Go
45 lines
1.3 KiB
Go
// Package version exposes build-time version and commit information for the
|
|
// ffd-indexer binaries.
|
|
//
|
|
// The values are injected at build time via the Go linker:
|
|
//
|
|
// go build -ldflags "-X git.xengi.de/ffd/indexer/internal/version.Version=1.2.3 \
|
|
// -X git.xengi.de/ffd/indexer/internal/version.Commit=a1b2c3d"
|
|
//
|
|
// (the flake sets these from `version` and `shortRev`). When built with a
|
|
// plain `go build`/`go run` the variables stay empty and the binary reports
|
|
// itself as the development build.
|
|
package version
|
|
|
|
import (
|
|
"fmt"
|
|
"runtime"
|
|
)
|
|
|
|
// Version is the application version, overridden at build time.
|
|
var Version = ""
|
|
|
|
// Commit is the git commit the binary was built from, overridden at build time.
|
|
var Commit = ""
|
|
|
|
// PrintFull writes the canonical multi-line version block to stdout. This is
|
|
// the human-readable format used by kubectl, docker, kind and friends:
|
|
//
|
|
// Version: 1.2.3
|
|
// Commit: a1b2c3d
|
|
// Go version: go1.27.1
|
|
//
|
|
// Empty values are printed as "dev" so the output is always self-explanatory.
|
|
func PrintFull() {
|
|
v := Version
|
|
if v == "" {
|
|
v = "dev"
|
|
}
|
|
c := Commit
|
|
if c == "" {
|
|
c = "dev"
|
|
}
|
|
fmt.Printf("Version: %s\n", v)
|
|
fmt.Printf("Commit: %s\n", c)
|
|
fmt.Printf("Go version: %s\n", runtime.Version())
|
|
}
|