Remove Buildarch from ldflags, use runtime.GOARCH instead

The architecture is available at runtime via stdlib, no need to bake
it in at build time.
This commit is contained in:
Jeffrey Paul 2026-01-08 12:38:24 -08:00
parent 15d9439e3d
commit 7d0ac0a139
4 changed files with 13 additions and 20 deletions

View File

@ -1,8 +1,7 @@
.PHONY: check lint test fmt build clean
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
BUILDARCH := $(shell go env GOARCH)
LDFLAGS := -X main.Version=$(VERSION) -X main.Buildarch=$(BUILDARCH)
LDFLAGS := -X main.Version=$(VERSION)
# Default target: run all checks
check: fmt-check lint test

View File

@ -20,7 +20,6 @@ import (
var (
Appname = "pixad" //nolint:gochecknoglobals // set by ldflags
Version string //nolint:gochecknoglobals // set by ldflags
Buildarch string //nolint:gochecknoglobals // set by ldflags
)
var configPath string //nolint:gochecknoglobals // cobra flag
@ -43,7 +42,6 @@ func main() {
func run(_ *cobra.Command, _ []string) {
globals.Appname = Appname
globals.Version = Version
globals.Buildarch = Buildarch
// Set config path in environment if specified via flag
if configPath != "" {

View File

@ -9,23 +9,18 @@ import (
var (
Appname string //nolint:gochecknoglobals // set from main
Version string //nolint:gochecknoglobals // set from main
Buildarch string //nolint:gochecknoglobals // set from main
)
// Globals holds application-wide constants.
type Globals struct {
Appname string
Version string
Buildarch string
}
// New creates a new Globals instance from build-time variables.
func New(_ fx.Lifecycle) (*Globals, error) {
n := &Globals{
return &Globals{
Appname: Appname,
Buildarch: Buildarch,
Version: Version,
}
return n, nil
}, nil
}

View File

@ -4,6 +4,7 @@ package logger
import (
"log/slog"
"os"
"runtime"
"go.uber.org/fx"
"sneak.berlin/go/pixa/internal/globals"
@ -72,6 +73,6 @@ func (l *Logger) Identify() {
l.log.Info("starting",
"appname", l.globals.Appname,
"version", l.globals.Version,
"buildarch", l.globals.Buildarch,
"arch", runtime.GOARCH,
)
}