fix regression reading build info

This commit is contained in:
onyx-and-iris 2025-06-19 02:07:25 +01:00
parent 856da5cd04
commit 4139c4b291

10
main.go
View File

@ -3,7 +3,9 @@ package main
import ( import (
"context" "context"
"log"
"os" "os"
"runtime/debug"
"strings" "strings"
"github.com/charmbracelet/fang" "github.com/charmbracelet/fang"
@ -56,6 +58,14 @@ func init() {
// main is the entry point of the application. // main is the entry point of the application.
// It executes the root command and handles any errors. // It executes the root command and handles any errors.
func main() { func main() {
if version == "" {
info, ok := debug.ReadBuildInfo()
if !ok {
log.Fatal("could not read build info")
}
version = strings.Split(info.Main.Version, "-")[0]
}
if err := fang.Execute(context.Background(), rootCmd, fang.WithVersion(version)); err != nil { if err := fang.Execute(context.Background(), rootCmd, fang.WithVersion(version)); err != nil {
os.Exit(1) os.Exit(1)
} }