From 25895a9dd842560562325a8ed2f6499ed0e0e6d4 Mon Sep 17 00:00:00 2001 From: Shivam Mehta Date: Sun, 24 Aug 2025 22:38:45 +0530 Subject: [PATCH 1/2] fix: add runtime version detection for go install - Use debug.ReadBuildInfo() to detect version from module info - Fixes TUI footer showing 'dev' when installed via go install - Falls back to injected version for release builds - Resolves version display for go install github.com/maniac-en/req@vX.Y.Z --- main.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index db79718..81772ec 100644 --- a/main.go +++ b/main.go @@ -9,6 +9,7 @@ import ( "log/slog" "os" "path/filepath" + "runtime/debug" tea "github.com/charmbracelet/bubbletea" "github.com/maniac-en/req/internal/backend/collections" @@ -38,6 +39,18 @@ var ( var Version = "dev" +func getVersion() string { + // Try to get version from build info (works with go install) + if info, ok := debug.ReadBuildInfo(); ok { + if info.Main.Version != "" && info.Main.Version != "(devel)" { + return info.Main.Version + } + } + + // Fall back to injected version (release builds) + return Version +} + func initPaths() error { // setup paths using OS-appropriate cache directory userHomeDir, err := os.UserHomeDir() @@ -141,7 +154,7 @@ func main() { endpointsManager, httpManager, historyManager, - Version, + getVersion(), ) // populate dummy data for demo From cb93a2d78f9fc8236ed3c99616d1760f2e81114c Mon Sep 17 00:00:00 2001 From: Shivam Mehta Date: Sun, 24 Aug 2025 22:40:18 +0530 Subject: [PATCH 2/2] chore: formatted via gofmt --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 81772ec..ff39d30 100644 --- a/main.go +++ b/main.go @@ -46,7 +46,7 @@ func getVersion() string { return info.Main.Version } } - + // Fall back to injected version (release builds) return Version }