* fix #1014

* remove unused code

* * optimize generate pb.go on Windows
* format code
* optimize console.go

* version rollback

Co-authored-by: anqiansong <anqiansong@bytedance.com>
This commit is contained in:
anqiansong
2021-09-11 12:48:32 +08:00
committed by GitHub
parent 6bf6cfdd01
commit f0ed2370a3
8 changed files with 135 additions and 93 deletions

View File

@@ -3,8 +3,11 @@ package console
import (
"fmt"
"os"
"runtime"
"github.com/logrusorgru/aurora"
"github.com/tal-tech/go-zero/tools/goctl/vars"
)
type (
@@ -46,22 +49,22 @@ func (c *colorConsole) Info(format string, a ...interface{}) {
func (c *colorConsole) Debug(format string, a ...interface{}) {
msg := fmt.Sprintf(format, a...)
fmt.Println(aurora.Blue(msg))
println(aurora.Blue(msg))
}
func (c *colorConsole) Success(format string, a ...interface{}) {
msg := fmt.Sprintf(format, a...)
fmt.Println(aurora.Green(msg))
println(aurora.Green(msg))
}
func (c *colorConsole) Warning(format string, a ...interface{}) {
msg := fmt.Sprintf(format, a...)
fmt.Println(aurora.Yellow(msg))
println(aurora.Yellow(msg))
}
func (c *colorConsole) Error(format string, a ...interface{}) {
msg := fmt.Sprintf(format, a...)
fmt.Println(aurora.Red(msg))
println(aurora.Red(msg))
}
func (c *colorConsole) Fatalln(format string, a ...interface{}) {
@@ -123,3 +126,18 @@ func (i *ideaConsole) Must(err error) {
i.Fatalln("%+v", err)
}
}
func println(msg interface{}) {
value, ok := msg.(aurora.Value)
if !ok {
fmt.Println(msg)
}
goos := runtime.GOOS
if goos == vars.OsWindows {
fmt.Println(value.Value())
return
}
fmt.Println(msg)
}

View File

@@ -5,6 +5,7 @@ import (
"os"
"path"
"path/filepath"
"runtime"
"strings"
"github.com/tal-tech/go-zero/tools/goctl/vars"
@@ -115,6 +116,12 @@ func FindProjectPath(loc string) (string, bool) {
// ReadLink returns the destination of the named symbolic link recursively.
func ReadLink(name string) (string, error) {
goos := runtime.GOOS
switch goos {
case vars.OsWindows:
return name, nil
}
name, err := filepath.Abs(name)
if err != nil {
return "", err