commit adbed3e99d088861771bdda8489146b5a4dbe852
parent 0f84fcdb8e79754763060b12e42cb60aab824e45
Author: Sean Enck <sean@ttypty.com>
Date: Thu, 5 Jun 2025 11:41:52 -0400
try harder to get version
Diffstat:
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/cmd/lb/main.go b/cmd/lb/main.go
@@ -6,6 +6,7 @@ import (
"fmt"
"os"
"os/exec"
+ "runtime/debug"
"strings"
"time"
@@ -34,7 +35,17 @@ func handleEarly(command string, args []string) (bool, error) {
}
switch command {
case commands.Version:
- fmt.Printf("version: %s\n", version)
+ vers := version
+ if vers == "" {
+ info, ok := debug.ReadBuildInfo()
+ if ok {
+ vers = info.Main.Version
+ }
+ }
+ if vers == "" {
+ vers = "(development)"
+ }
+ fmt.Printf("version: %s\n", vers)
return true, nil
case commands.Clear:
return true, clearClipboard()