Files
netwatch/internal/globals/globals.go
T
sneak 84213bf29f
check / check (push) Canceled after 0s
main() is one call into internal/cli (closes #160)
cmd/netwatch-server/main.go parsed the command line, ran the check-cidr
and prepare-data-dir subcommands and built the fx application itself;
the Go style guide puts all of that in internal/ or pkg/. The new
package internal/cli does it, with the same arguments, messages and
exit codes. main() is now os.Exit(cli.Main(Appname, Version,
os.Args[1:], cli.RunServer)): Main takes the function that runs the
server, so its tests call it with one that fails them. Appname and
Version stay in main, where the build sets Version. Each subcommand
writes its error to a writer it is given, and prepare-data-dir also
takes the volume and the user's name, so its own tests give it a
temporary directory and the user they run as.

Model: opus-5-5
2026-10-19 04:48:51 +00:00

28 lines
637 B
Go

// Package globals provides build-time variables injected via
// ldflags and made available through dependency injection.
package globals
import "go.uber.org/fx"
//nolint:gochecknoglobals // set by cli.RunServer before fx starts
var (
// Appname is the application name.
Appname string
// Version is the git version tag.
Version string
)
// Globals holds build-time metadata for the application.
type Globals struct {
Appname string
Version string
}
// New creates a Globals instance from package-level variables.
func New(_ fx.Lifecycle) (*Globals, error) {
return &Globals{
Appname: Appname,
Version: Version,
}, nil
}