buildinfo

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package buildinfo resolves the running binary's version metadata. It reads ldflags-injected overrides (set via `-X` at build time) and falls back to `runtime/debug.ReadBuildInfo()` when the overrides are sentinel values, so `go install module@version` binaries still report useful metadata.

Index

Constants

This section is empty.

Variables

View Source
var (
	Version = "dev"
	Commit  = "unknown"
	Date    = "unknown"
)

Set via -ldflags at build time (see Makefile). These act as overrides. They are package-level var so the linker can write to them; keep the names stable — the Makefile's LDFLAGS refers to them by full symbol path (github.com/RandomCodeSpace/docsiq/internal/buildinfo.Version etc.).

Functions

This section is empty.

Types

type Info

type Info struct {
	Version   string            `json:"version"`
	Commit    string            `json:"commit"`
	BuildDate string            `json:"build_date"`
	GoVersion string            `json:"go_version"`
	Dirty     string            `json:"dirty"` // "true", "false", or "unknown"
	Deps      map[string]string `json:"deps,omitempty"`
}

Info holds resolved version metadata for the running binary.

func Resolve

func Resolve(includeDeps bool) Info

Resolve returns the current version metadata using:

  1. -ldflags overrides (if non-sentinel)
  2. runtime/debug.ReadBuildInfo() (module version + VCS settings)
  3. "unknown" for any remaining field

When includeDeps is true, the returned Info also lists the main module's direct dependencies (Path → Version). Transitive deps are omitted because they bloat the response without real diagnostic value.

Jump to

Keyboard shortcuts

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