From e85b5ff033afe9f6dc7947a1fb0cbcaf4d60ed11 Mon Sep 17 00:00:00 2001 From: clawbot Date: Fri, 20 Mar 2026 07:04:54 +0100 Subject: [PATCH] Consolidate appname to internal/globals as a constant (#34) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes [issue #30](https://git.eeqj.de/sneak/pixa/issues/30). The appname `"pixad"` was redundantly defined in both `cmd/pixad/main.go` (as a package-level var) and `internal/globals/globals.go` (as a package-level var that got copied from main). Since the appname is always `"pixad"` and is not actually set via ldflags (only `Version` is), this PR: - Defines `appname` once as an unexported constant in `internal/globals/globals.go` - Removes the `Appname` var from `cmd/pixad/main.go` - Removes the `globals.Appname = Appname` assignment from `main.run()` - Keeps `Version` flow unchanged (still set via ldflags in main, passed to globals) The `Globals.Appname` struct field remains available to all consumers — they just get it from the constant now instead of a package var that was always `"pixad"`. All existing tests pass, `docker build .` succeeds. Co-authored-by: user Co-authored-by: Jeffrey Paul Reviewed-on: https://git.eeqj.de/sneak/pixa/pulls/34 Co-authored-by: clawbot Co-committed-by: clawbot --- cmd/pixad/main.go | 6 +----- internal/globals/globals.go | 11 +++++------ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/cmd/pixad/main.go b/cmd/pixad/main.go index 5dcaf0b..7dc11cd 100644 --- a/cmd/pixad/main.go +++ b/cmd/pixad/main.go @@ -17,10 +17,7 @@ import ( "sneak.berlin/go/pixa/internal/server" ) -var ( - Appname = "pixad" //nolint:gochecknoglobals // set by ldflags - Version string //nolint:gochecknoglobals // set by ldflags -) +var Version string //nolint:gochecknoglobals // set by ldflags var configPath string //nolint:gochecknoglobals // cobra flag @@ -40,7 +37,6 @@ func main() { } func run(_ *cobra.Command, _ []string) { - globals.Appname = Appname globals.Version = Version // Set config path in environment if specified via flag diff --git a/internal/globals/globals.go b/internal/globals/globals.go index 5b86205..ac00731 100644 --- a/internal/globals/globals.go +++ b/internal/globals/globals.go @@ -5,11 +5,10 @@ import ( "go.uber.org/fx" ) -// Build-time variables populated from main() via ldflags. -var ( - Appname string //nolint:gochecknoglobals // set from main - Version string //nolint:gochecknoglobals // set from main -) +const appname = "pixad" + +// Version is populated from main() via ldflags. +var Version string //nolint:gochecknoglobals // set from main // Globals holds application-wide constants. type Globals struct { @@ -20,7 +19,7 @@ type Globals struct { // New creates a new Globals instance from build-time variables. func New(_ fx.Lifecycle) (*Globals, error) { return &Globals{ - Appname: Appname, + Appname: appname, Version: Version, }, nil }