github.com/easysoft/zendata@v0.0.0-20240513203326-705bd5a7fd67/cmd/launcher/main.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "os" 6 "os/exec" 7 "os/signal" 8 "syscall" 9 10 commonUtils "github.com/easysoft/zendata/pkg/utils/common" 11 "github.com/fatih/color" 12 ) 13 14 func main() { 15 channel := make(chan os.Signal) 16 signal.Notify(channel, os.Interrupt, syscall.SIGTERM) 17 go func() { 18 <-channel 19 cleanup() 20 os.Exit(0) 21 }() 22 23 pth := "" 24 var cmd *exec.Cmd 25 if commonUtils.IsWin() { 26 pth = "gui\\zd.exe" 27 cmd = exec.Command("cmd", "/C", "start", pth) 28 } 29 30 err := cmd.Run() 31 if err != nil { 32 fmt.Printf("Failed to start zd gui, path %s, err %s", pth, err.Error()) 33 } 34 } 35 36 func init() { 37 cleanup() 38 } 39 40 func cleanup() { 41 color.Unset() 42 }