// Package globals provides build-time variables injected via ldflags. package globals import ( "runtime" "go.uber.org/fx" ) // Build-time variables populated from main() and copied into the // Globals object. main() sets them from its own ldflags-injected // values; nothing else writes them. // //nolint:gochecknoglobals // Build-time variables set by main(). var ( Appname string Version string Buildarch string ) // Globals holds build-time metadata about the application. type Globals struct { Appname string Version string Buildarch string } // New creates a Globals instance from the package-level build-time // variables. // //nolint:revive // lc parameter is required by fx even if unused. func New(lc fx.Lifecycle) (*Globals, error) { arch := Buildarch if arch == "" { arch = runtime.GOARCH } return &Globals{ Appname: Appname, Buildarch: arch, Version: Version, }, nil }