diff --git a/Makefile b/Makefile index fe266fc..0aadca3 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,7 @@ BINARY := dnswatcher 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) all: check build diff --git a/README.md b/README.md index 7c87c2e..eb52839 100644 --- a/README.md +++ b/README.md @@ -171,7 +171,7 @@ cmd/dnswatcher/main.go Entry point (uber/fx bootstrap) internal/ config/config.go Viper-based configuration - globals/globals.go Build-time variables (version, arch) + globals/globals.go Build-time variables (version) logger/logger.go slog structured logging (TTY detection) healthcheck/healthcheck.go Health check service middleware/middleware.go HTTP middleware (logging, CORS, metrics auth) @@ -363,11 +363,10 @@ make clean # Remove build artifacts ### Build-Time Variables -Version and architecture are injected via `-ldflags`: +Version is injected via `-ldflags`: ```sh -go build -ldflags "-X main.Version=$(git describe --tags --always) \ - -X main.Buildarch=$(go env GOARCH)" ./cmd/dnswatcher +go build -ldflags "-X main.Version=$(git describe --tags --always)" ./cmd/dnswatcher ``` --- diff --git a/cmd/dnswatcher/main.go b/cmd/dnswatcher/main.go index 03b38da..baff13b 100644 --- a/cmd/dnswatcher/main.go +++ b/cmd/dnswatcher/main.go @@ -25,15 +25,13 @@ import ( // //nolint:gochecknoglobals // build-time variables var ( - Appname = "dnswatcher" - Version string - Buildarch string + Appname = "dnswatcher" + Version string ) func main() { globals.SetAppname(Appname) globals.SetVersion(Version) - globals.SetBuildarch(Buildarch) fx.New( fx.Provide( diff --git a/internal/config/config_test.go b/internal/config/config_test.go index c460d56..0ee5c83 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -19,9 +19,8 @@ func newTestParams(t *testing.T) config.Params { t.Helper() g := &globals.Globals{ - Appname: "dnswatcher", - Version: "test", - Buildarch: "amd64", + Appname: "dnswatcher", + Version: "test", } l, err := logger.New(nil, logger.Params{Globals: g}) diff --git a/internal/globals/globals.go b/internal/globals/globals.go index 02ce645..0b51cff 100644 --- a/internal/globals/globals.go +++ b/internal/globals/globals.go @@ -12,17 +12,15 @@ import ( // //nolint:gochecknoglobals // Required for ldflags injection at build time var ( - mu sync.RWMutex - appname string - version string - buildarch string + mu sync.RWMutex + appname string + version string ) // Globals holds build-time variables for dependency injection. type Globals struct { - Appname string - Version string - Buildarch string + Appname string + Version string } // New creates a new Globals instance from package-level variables. @@ -31,9 +29,8 @@ func New(_ fx.Lifecycle) (*Globals, error) { defer mu.RUnlock() return &Globals{ - Appname: appname, - Version: version, - Buildarch: buildarch, + Appname: appname, + Version: version, }, nil } @@ -52,11 +49,3 @@ func SetVersion(ver string) { version = ver } - -// SetBuildarch sets the build architecture. -func SetBuildarch(arch string) { - mu.Lock() - defer mu.Unlock() - - buildarch = arch -} diff --git a/internal/logger/logger.go b/internal/logger/logger.go index 0bcdd28..8aaaad1 100644 --- a/internal/logger/logger.go +++ b/internal/logger/logger.go @@ -78,6 +78,5 @@ func (l *Logger) Identify() { l.log.Info("starting", "appname", l.params.Globals.Appname, "version", l.params.Globals.Version, - "buildarch", l.params.Globals.Buildarch, ) }