Goctl rpc patch (#117)
* remove mock generation * add: proto project import * update document * remove mock generation * add: proto project import * update document * remove NL * update document * optimize code * add test * add test
This commit is contained in:
@@ -11,9 +11,11 @@ type (
|
||||
Console interface {
|
||||
Success(format string, a ...interface{})
|
||||
Info(format string, a ...interface{})
|
||||
Debug(format string, a ...interface{})
|
||||
Warning(format string, a ...interface{})
|
||||
Error(format string, a ...interface{})
|
||||
Fatalln(format string, a ...interface{})
|
||||
MarkDone()
|
||||
Must(err error)
|
||||
}
|
||||
colorConsole struct {
|
||||
@@ -39,6 +41,11 @@ func (c *colorConsole) Info(format string, a ...interface{}) {
|
||||
fmt.Println(msg)
|
||||
}
|
||||
|
||||
func (c *colorConsole) Debug(format string, a ...interface{}) {
|
||||
msg := fmt.Sprintf(format, a...)
|
||||
fmt.Println(aurora.Blue(msg))
|
||||
}
|
||||
|
||||
func (c *colorConsole) Success(format string, a ...interface{}) {
|
||||
msg := fmt.Sprintf(format, a...)
|
||||
fmt.Println(aurora.Green(msg))
|
||||
@@ -59,6 +66,10 @@ func (c *colorConsole) Fatalln(format string, a ...interface{}) {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func (c *colorConsole) MarkDone() {
|
||||
c.Success("Done.")
|
||||
}
|
||||
|
||||
func (c *colorConsole) Must(err error) {
|
||||
if err != nil {
|
||||
c.Fatalln("%+v", err)
|
||||
@@ -74,6 +85,11 @@ func (i *ideaConsole) Info(format string, a ...interface{}) {
|
||||
fmt.Println(msg)
|
||||
}
|
||||
|
||||
func (i *ideaConsole) Debug(format string, a ...interface{}) {
|
||||
msg := fmt.Sprintf(format, a...)
|
||||
fmt.Println(aurora.Blue(msg))
|
||||
}
|
||||
|
||||
func (i *ideaConsole) Success(format string, a ...interface{}) {
|
||||
msg := fmt.Sprintf(format, a...)
|
||||
fmt.Println("[SUCCESS]: ", msg)
|
||||
@@ -94,6 +110,10 @@ func (i *ideaConsole) Fatalln(format string, a ...interface{}) {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func (i *ideaConsole) MarkDone() {
|
||||
i.Success("Done.")
|
||||
}
|
||||
|
||||
func (i *ideaConsole) Must(err error) {
|
||||
if err != nil {
|
||||
i.Fatalln("%+v", err)
|
||||
|
||||
@@ -10,6 +10,10 @@ import (
|
||||
"github.com/logrusorgru/aurora"
|
||||
)
|
||||
|
||||
const (
|
||||
NL = "\n"
|
||||
)
|
||||
|
||||
func CreateIfNotExist(file string) (*os.File, error) {
|
||||
_, err := os.Stat(file)
|
||||
if !os.IsNotExist(err) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package project
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -38,18 +39,18 @@ type (
|
||||
func Prepare(projectDir string, checkGrpcEnv bool) (*Project, error) {
|
||||
_, err := exec.LookPath(constGo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("please install go first,reference documents:「https://golang.org/doc/install」")
|
||||
}
|
||||
|
||||
if checkGrpcEnv {
|
||||
_, err = exec.LookPath(constProtoC)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("please install protoc first,reference documents:「https://github.com/golang/protobuf」")
|
||||
}
|
||||
|
||||
_, err = exec.LookPath(constProtoCGenGo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("please install plugin protoc-gen-go first,reference documents:「https://github.com/golang/protobuf」")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user