feat: replaced color package to support Windows (#3207)

This commit is contained in:
ALMAS
2023-05-05 21:09:54 +08:00
committed by GitHub
parent 8ad0668612
commit 774e8d1d08
16 changed files with 55 additions and 85 deletions

View File

@@ -11,7 +11,7 @@ import (
"sync"
"time"
"github.com/logrusorgru/aurora"
"github.com/gookit/color"
"github.com/spf13/cobra"
"github.com/zeromicro/go-zero/core/logx"
apiformat "github.com/zeromicro/go-zero/tools/goctl/api/format"
@@ -109,7 +109,7 @@ func DoGenProject(apiFile, dir, style string) error {
return err
}
fmt.Println(aurora.Green("Done."))
fmt.Println(color.Green.Render("Done."))
return nil
}
@@ -152,14 +152,14 @@ func sweep() error {
seconds, err := strconv.ParseInt(timestamp, 10, 64)
if err != nil {
// print error and ignore
fmt.Println(aurora.Red(fmt.Sprintf("sweep ignored file: %s", fpath)))
fmt.Println(color.Red.Sprintf("sweep ignored file: %s", fpath))
return nil
}
tm := time.Unix(seconds, 0)
if tm.Before(keepTime) {
if err := os.RemoveAll(fpath); err != nil {
fmt.Println(aurora.Red(fmt.Sprintf("failed to remove file: %s", fpath)))
fmt.Println(color.Red.Sprintf("failed to remove file: %s", fpath))
return err
}
}