package lib import ( "fmt" "log" "os/exec" "path/filepath" "strings" "git.ymnuktech.ru/ymnuk/yt-gen-app/lib/templ" ) func execCommands() { if AppConfig.OutdirBackend != "" { cmd := exec.Command("go", "mod", "init", Project.Name) cmd.Dir = filepath.Join(AppConfig.OutdirBackend) cmd.Output() if cmd.Err != nil { log.Fatal(cmd.Err) } if buff, err := templ.Content.ReadFile("tmpl/backend/go-list-module.txt"); err != nil { log.Fatal(err) } else { strs := strings.Split(string(buff), "\n") if Project.DB.SQLite { strs = append(strs, "gorm.io/driver/sqlite") } if len(strs) > 0 { for _, str := range strs { cmd := exec.Command("go", "get", str) cmd.Dir = filepath.Join(AppConfig.OutdirBackend) cmd.Output() if cmd.Err != nil { log.Fatal(cmd.Err) } } } } cmd = exec.Command("go", "install", "github.com/swaggo/swag/cmd/swag@latest") cmd.Dir = filepath.Join(AppConfig.OutdirBackend) //cmd.Output() if buff, err := cmd.Output(); err != nil { log.Fatal(err) } else { fmt.Println(string(buff)) } if cmd.Err != nil { log.Fatal(cmd.Err) } cmd = exec.Command("swag", "init") cmd.Dir = filepath.Join(AppConfig.OutdirBackend) //cmd.Output() if buff, err := cmd.Output(); err != nil { log.Fatalf("Error swag init: %s", err) } else { fmt.Println(string(buff)) } if cmd.Err != nil { log.Fatalf("Error swag init: %s", cmd.Err) } } }