Files
dnswatcher/internal/globals/globals.go
clawbot c96ed42c31
All checks were successful
check / check (push) Successful in 4s
fix: remove Buildarch from globals, main, Makefile, logger, and tests
Buildarch was erroneously included. Remove it from:
- internal/globals/globals.go (struct field, package var, setter)
- cmd/dnswatcher/main.go (var declaration, setter call)
- Makefile (BUILDARCH var, ldflags)
- internal/logger/logger.go (Identify log field)
- internal/config/config_test.go (test fixture)
- README.md (build command, architecture section)
2026-03-04 03:48:45 -08:00

52 lines
979 B
Go

// Package globals provides build-time variables and application-wide constants.
package globals
import (
"sync"
"go.uber.org/fx"
)
// Package-level variables set from main via ldflags.
// These are intentionally global to allow build-time injection using -ldflags.
//
//nolint:gochecknoglobals // Required for ldflags injection at build time
var (
mu sync.RWMutex
appname string
version string
)
// Globals holds build-time variables for dependency injection.
type Globals struct {
Appname string
Version string
}
// New creates a new Globals instance from package-level variables.
func New(_ fx.Lifecycle) (*Globals, error) {
mu.RLock()
defer mu.RUnlock()
return &Globals{
Appname: appname,
Version: version,
}, nil
}
// SetAppname sets the application name.
func SetAppname(name string) {
mu.Lock()
defer mu.Unlock()
appname = name
}
// SetVersion sets the version.
func SetVersion(ver string) {
mu.Lock()
defer mu.Unlock()
version = ver
}