From 1770b8369467ca3f698bd948c634d11d4594240e Mon Sep 17 00:00:00 2001 From: Eltrac Date: Fri, 21 Nov 2025 09:23:02 +0800 Subject: refactor: use cmd.Output instead of a bytes.Buffer --- brewget.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/brewget.go b/brewget.go index dc05520..5bc38f2 100644 --- a/brewget.go +++ b/brewget.go @@ -1,7 +1,6 @@ package main import ( - "bytes" "encoding/json" "github.com/fatih/color" "os/exec" @@ -63,16 +62,14 @@ func GetBrewInfo(pkg string) (*FormulaInfo, *CaskInfo) { } func GetBrewUses(pkg string) []string { - cmd := exec.Command("brew", "uses", "--installed", pkg) - var out bytes.Buffer - cmd.Stdout = &out - if err := cmd.Run(); err != nil { + out, err := exec.Command("brew", "uses", "--installed", pkg).Output() + if err != nil { color.Red("❌ Error fetching reverse dependencies.") return []string{} } // Each line is a formula name - lines := strings.Split(strings.TrimSpace(out.String()), "\n") + lines := strings.Split(strings.TrimSpace(string(out)), "\n") if len(lines) == 1 && lines[0] == "" { return []string{} } -- cgit v1.2.3