buildinfo

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package buildinfo carries the values stamped into the binary at link time (§16.4) and degrades gracefully when they are absent.

cmd/pay/main.go declares the -X targets (main.version / main.commit / main.date) and hands them to Set before anything else runs. When the binary was produced by "go install .../cmd/pay@latest" instead of goreleaser, the ldflags are empty and the module version plus VCS stamps recorded by the Go toolchain in debug.ReadBuildInfo are used instead, so `pay version` reports something more useful than "dev".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Commit

func Commit() string

Commit is the VCS revision the binary was built from, or "" when unknown.

func Date

func Date() string

Date is the build timestamp, or "" when unknown.

func Set

func Set(version, commit, date string)

Set records the link-time values. It is called exactly once, from cmd/pay/main.go, before any other package runs.

func UserAgent

func UserAgent() string

UserAgent is the value the transport sends (§6); it is derived here so the version string has exactly one source.

func Version

func Version() string

Version is the shorthand used by meta.cli_version in every envelope (§10.1).

Types

type Info

type Info struct {
	Version     string `json:"version"`
	Commit      string `json:"commit"`
	Date        string `json:"date"`
	Go          string `json:"go"`
	OS          string `json:"os"`
	Arch        string `json:"arch"`
	InstallPath string `json:"install_path"`
	Managed     bool   `json:"managed"`
}

Info is the payload of `pay version --output json` (§16.4). InstallPath and Managed are filled in by the caller (internal/update knows whether the binary sits in a package-manager-owned location); every other field is resolved here.

func Current

func Current() Info

Current returns the resolved build information, computing it from debug.ReadBuildInfo alone when Set was never called (which is the case in unit tests and in `go run`).

Jump to

Keyboard shortcuts

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