-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuninstall.go
46 lines (37 loc) · 885 Bytes
/
uninstall.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"fmt"
"log"
"sync"
"github.com/spf13/cobra"
)
var uninstallCmd = &cobra.Command{
Use: "uninstall",
Short: "Удалить инструменты",
Run: uninstallRun,
}
func uninstallRun(cmd *cobra.Command, args []string) {
osType := detectOS()
fmt.Printf("Обнаруженная ОС: %s\n", osType)
stackStr := selectStack()
tools := selectStackTools(stackStr)
var wg sync.WaitGroup
errorsCh := make(chan error, len(tools))
for _, toolName := range tools {
if tool, ok := availableTools[toolName]; ok {
wg.Add(1)
go func(tool Tool) {
defer wg.Done()
err := tool.uninstall(osType)
if err != nil {
errorsCh <- fmt.Errorf("ошибка удаления %s: %v", tool.Description, err)
}
}(tool)
}
}
wg.Wait()
close(errorsCh)
for err := range errorsCh {
log.Printf("Ошибка: %v\n", err)
}
}