Skip to content

Commit 4a0a9aa

Browse files
authored
release: v0.1.0-alpha.2
Fix version detection for go install (#62)
1 parent c9a5801 commit 4a0a9aa

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

main.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"log/slog"
1010
"os"
1111
"path/filepath"
12+
"runtime/debug"
1213

1314
tea "github.com/charmbracelet/bubbletea"
1415
"github.com/maniac-en/req/internal/backend/collections"
@@ -38,6 +39,18 @@ var (
3839

3940
var Version = "dev"
4041

42+
func getVersion() string {
43+
// Try to get version from build info (works with go install)
44+
if info, ok := debug.ReadBuildInfo(); ok {
45+
if info.Main.Version != "" && info.Main.Version != "(devel)" {
46+
return info.Main.Version
47+
}
48+
}
49+
50+
// Fall back to injected version (release builds)
51+
return Version
52+
}
53+
4154
func initPaths() error {
4255
// setup paths using OS-appropriate cache directory
4356
userHomeDir, err := os.UserHomeDir()
@@ -141,7 +154,7 @@ func main() {
141154
endpointsManager,
142155
httpManager,
143156
historyManager,
144-
Version,
157+
getVersion(),
145158
)
146159

147160
// populate dummy data for demo

0 commit comments

Comments
 (0)