Seed from go-template-repo, renamed to simplexcalc
The template's files at a77fd30, without its history or LICENSE, after script/rename simplexcalc. Model: opus-5-5
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
// 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
|
||||
}
|
||||
Reference in New Issue
Block a user