mirror of
https://github.com/gesellix/Bose-SoundTouch.git
synced 2026-08-19 09:06:14 +00:00
refactor: Replace getBuildInfo() with updateBuildInfo() for consistency
- Use package-level variables instead of mixed return/ignore pattern - Call updateBuildInfo() once at startup instead of multiple function calls - Cleaner, more consistent design with single responsibility - Eliminates confusing 'version, _, _' usage pattern Thanks for the excellent code review feedback!
This commit is contained in:
@@ -150,7 +150,6 @@ func PrintWarning(message string) {
|
||||
|
||||
// showVersionInfo displays detailed version information including build details
|
||||
func showVersionInfo(_ *cli.Context) error {
|
||||
version, commit, date := getBuildInfo()
|
||||
fmt.Printf("soundtouch-cli version %s\n", version)
|
||||
fmt.Printf("Build commit: %s\n", commit)
|
||||
fmt.Printf("Build date: %s\n", date)
|
||||
|
||||
@@ -9,12 +9,15 @@ import (
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// getBuildInfo extracts version information from debug.BuildInfo
|
||||
func getBuildInfo() (version, commit, date string) {
|
||||
// Package-level variables for build information
|
||||
var (
|
||||
version = "dev"
|
||||
commit = "unknown"
|
||||
date = "unknown"
|
||||
commit = "unknown"
|
||||
date = "unknown"
|
||||
)
|
||||
|
||||
// updateBuildInfo extracts version information from debug.BuildInfo and updates package variables
|
||||
func updateBuildInfo() {
|
||||
if info, ok := debug.ReadBuildInfo(); ok {
|
||||
// Get version from module info
|
||||
if info.Main.Version != "" && info.Main.Version != "(devel)" {
|
||||
@@ -33,12 +36,10 @@ func getBuildInfo() (version, commit, date string) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func main() {
|
||||
version, _, _ := getBuildInfo()
|
||||
updateBuildInfo()
|
||||
|
||||
app := &cli.App{
|
||||
Name: "soundtouch-cli",
|
||||
|
||||
Reference in New Issue
Block a user