buildinfo

package
v1.38.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2026 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package buildinfo exposes the build-time version string used by both the PeeringDB User-Agent and the OTel resource so they stay in lockstep.

Resolution order:

  1. injected: set with ldflags `-X github.com/dotwaffle/peeringdb-plus/internal/buildinfo.injected=<value>` only when a Docker build gets an explicit VERSION build argument, for a build context without .git.
  2. Main.Version from runtime/debug.ReadBuildInfo. `go build` in a git checkout stamps it (Go 1.24 and later): the tag on a tagged commit (v1.32.0), a pseudo-version between tags (v1.32.1-0.20260925001332-10674814d276), and a +dirty suffix when the tree differs from the commit. This is the production path: both Dockerfiles keep .git and every tracked file in the build context. `go install` of a tagged module path also sets it.
  3. vcs.revision (first 7 chars) from build settings, for a build that recorded the commit but no module version.
  4. Literal "unknown": last resort.

A `go test` binary has no version stamp and falls through to (3) or (4). The peeringdb User-Agent test asserts the surrounding shape, not the version literal, so test runs stay stable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SourceTime added in v1.25.0

func SourceTime() time.Time

SourceTime returns the UTC source timestamp recorded by the Go toolchain. It returns the zero time when build information or vcs.time is unavailable or malformed.

func Version

func Version() string

Version returns the resolved build version. See package doc for the resolution order. The result is computed once per call but is cheap; callers may still cache at package init if they need a stable string.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL