summaryrefslogtreecommitdiff
path: root/brewget.go
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-11-21 09:23:02 +0800
committerEltrac <hi@guhub.cn>2025-11-21 09:23:02 +0800
commit1770b8369467ca3f698bd948c634d11d4594240e (patch)
tree073a7d7758c2e46cd71287fc15764f3bfb1371eb /brewget.go
parent2961ec7676e88f1cb05aac4650c6d2101bff0d1a (diff)
refactor: use cmd.Output instead of a bytes.Buffer
Diffstat (limited to 'brewget.go')
-rw-r--r--brewget.go9
1 files 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{}
}