fix spelling (#551)
This commit is contained in:
@@ -33,7 +33,7 @@ func (v *ApiVisitor) VisitApi(ctx *api.ApiContext) interface{} {
|
|||||||
for _, each := range ctx.AllSpec() {
|
for _, each := range ctx.AllSpec() {
|
||||||
root := each.Accept(v).(*Api)
|
root := each.Accept(v).(*Api)
|
||||||
v.acceptSyntax(root, &final)
|
v.acceptSyntax(root, &final)
|
||||||
v.accetpImport(root, &final)
|
v.acceptImport(root, &final)
|
||||||
v.acceptInfo(root, &final)
|
v.acceptInfo(root, &final)
|
||||||
v.acceptType(root, &final)
|
v.acceptType(root, &final)
|
||||||
v.acceptService(root, &final)
|
v.acceptService(root, &final)
|
||||||
@@ -133,7 +133,7 @@ func (v *ApiVisitor) acceptInfo(root *Api, final *Api) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *ApiVisitor) accetpImport(root *Api, final *Api) {
|
func (v *ApiVisitor) acceptImport(root *Api, final *Api) {
|
||||||
for _, imp := range root.Import {
|
for _, imp := range root.Import {
|
||||||
if _, ok := final.importM[imp.Value.Text()]; ok {
|
if _, ok := final.importM[imp.Value.Text()]; ok {
|
||||||
v.panic(imp.Import, fmt.Sprintf("duplicate import '%s'", imp.Value.Text()))
|
v.panic(imp.Import, fmt.Sprintf("duplicate import '%s'", imp.Value.Text()))
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ type AtDoc struct {
|
|||||||
Kv []*KvExpr
|
Kv []*KvExpr
|
||||||
}
|
}
|
||||||
|
|
||||||
// AtHandler describes service hander ast for api syntax
|
// AtHandler describes service handler ast for api syntax
|
||||||
type AtHandler struct {
|
type AtHandler struct {
|
||||||
AtHandlerToken Expr
|
AtHandlerToken Expr
|
||||||
Name Expr
|
Name Expr
|
||||||
@@ -630,7 +630,7 @@ func (s *Service) Equal(v interface{}) bool {
|
|||||||
return s.ServiceApi.Equal(service.ServiceApi)
|
return s.ServiceApi.Equal(service.ServiceApi)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get returns the tergate KV by specified key
|
// Get returns the target KV by specified key
|
||||||
func (kv KV) Get(key string) Expr {
|
func (kv KV) Get(key string) Expr {
|
||||||
for _, each := range kv {
|
for _, each := range kv {
|
||||||
if each.Key.Text() == key {
|
if each.Key.Text() == key {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ type (
|
|||||||
NameExpr() Expr
|
NameExpr() Expr
|
||||||
}
|
}
|
||||||
|
|
||||||
// TypeAlias describes alias ast for api syatax
|
// TypeAlias describes alias ast for api syntax
|
||||||
TypeAlias struct {
|
TypeAlias struct {
|
||||||
Name Expr
|
Name Expr
|
||||||
Assign Expr
|
Assign Expr
|
||||||
@@ -26,7 +26,7 @@ type (
|
|||||||
CommentExpr Expr
|
CommentExpr Expr
|
||||||
}
|
}
|
||||||
|
|
||||||
// TypeStruct describes structure ast for api syatax
|
// TypeStruct describes structure ast for api syntax
|
||||||
TypeStruct struct {
|
TypeStruct struct {
|
||||||
Name Expr
|
Name Expr
|
||||||
Struct Expr
|
Struct Expr
|
||||||
@@ -225,7 +225,7 @@ func (v *ApiVisitor) VisitTypeBlockAlias(ctx *api.TypeBlockAliasContext) interfa
|
|||||||
alias.DocExpr = v.getDoc(ctx)
|
alias.DocExpr = v.getDoc(ctx)
|
||||||
alias.CommentExpr = v.getComment(ctx)
|
alias.CommentExpr = v.getComment(ctx)
|
||||||
// todo: reopen if necessary
|
// todo: reopen if necessary
|
||||||
v.panic(alias.Name, "unsupport alias")
|
v.panic(alias.Name, "unsupported alias")
|
||||||
return &alias
|
return &alias
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,7 +238,7 @@ func (v *ApiVisitor) VisitTypeAlias(ctx *api.TypeAliasContext) interface{} {
|
|||||||
alias.DocExpr = v.getDoc(ctx)
|
alias.DocExpr = v.getDoc(ctx)
|
||||||
alias.CommentExpr = v.getComment(ctx)
|
alias.CommentExpr = v.getComment(ctx)
|
||||||
// todo: reopen if necessary
|
// todo: reopen if necessary
|
||||||
v.panic(alias.Name, "unsupport alias")
|
v.panic(alias.Name, "unsupported alias")
|
||||||
return &alias
|
return &alias
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,7 +319,7 @@ func (v *ApiVisitor) VisitDataType(ctx *api.DataTypeContext) interface{} {
|
|||||||
if ctx.GetTime() != nil {
|
if ctx.GetTime() != nil {
|
||||||
// todo: reopen if it is necessary
|
// todo: reopen if it is necessary
|
||||||
timeExpr := v.newExprWithToken(ctx.GetTime())
|
timeExpr := v.newExprWithToken(ctx.GetTime())
|
||||||
v.panic(timeExpr, "unsupport time.Time")
|
v.panic(timeExpr, "unsupported time.Time")
|
||||||
return &Time{Literal: timeExpr}
|
return &Time{Literal: timeExpr}
|
||||||
}
|
}
|
||||||
if ctx.PointerType() != nil {
|
if ctx.PointerType() != nil {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TsCommand provides the entry to generting typescript codes
|
// TsCommand provides the entry to generate typescript codes
|
||||||
func TsCommand(c *cli.Context) error {
|
func TsCommand(c *cli.Context) error {
|
||||||
apiFile := c.String("api")
|
apiFile := c.String("api")
|
||||||
dir := c.String("dir")
|
dir := c.String("dir")
|
||||||
|
|||||||
@@ -11,15 +11,15 @@ import (
|
|||||||
|
|
||||||
// Key describes cache key
|
// Key describes cache key
|
||||||
type Key struct {
|
type Key struct {
|
||||||
// VarLeft describes the varible of cache key expression which likes cacheUserIdPrefix
|
// VarLeft describes the variable of cache key expression which likes cacheUserIdPrefix
|
||||||
VarLeft string
|
VarLeft string
|
||||||
// VarRight describes the value of cache key expression which likes "cache#user#id#"
|
// VarRight describes the value of cache key expression which likes "cache#user#id#"
|
||||||
VarRight string
|
VarRight string
|
||||||
// VarExpression describes the cache key expression which likes cacheUserIdPrefix = "cache#user#id#"
|
// VarExpression describes the cache key expression which likes cacheUserIdPrefix = "cache#user#id#"
|
||||||
VarExpression string
|
VarExpression string
|
||||||
// KeyLeft describes the varible of key definiation expression which likes userKey
|
// KeyLeft describes the variable of key definition expression which likes userKey
|
||||||
KeyLeft string
|
KeyLeft string
|
||||||
// KeyRight describes the value of key definiation expression which likes fmt.Sprintf("%s%v", cacheUserPrefix, user)
|
// KeyRight describes the value of key definition expression which likes fmt.Sprintf("%s%v", cacheUserPrefix, user)
|
||||||
KeyRight string
|
KeyRight string
|
||||||
// DataKeyRight describes data key likes fmt.Sprintf("%s%v", cacheUserPrefix, data.User)
|
// DataKeyRight describes data key likes fmt.Sprintf("%s%v", cacheUserPrefix, data.User)
|
||||||
DataKeyRight string
|
DataKeyRight string
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
|
|
||||||
const templateParentPath = "/"
|
const templateParentPath = "/"
|
||||||
|
|
||||||
// GenTemplates wtites the latest template text into file which is not exists
|
// GenTemplates writes the latest template text into file which is not exists
|
||||||
func GenTemplates(ctx *cli.Context) error {
|
func GenTemplates(ctx *cli.Context) error {
|
||||||
if err := errorx.Chain(
|
if err := errorx.Chain(
|
||||||
func() error {
|
func() error {
|
||||||
@@ -70,8 +70,8 @@ func CleanTemplates(_ *cli.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateTemplates wtites the latest template text into file,
|
// UpdateTemplates writes the latest template text into file,
|
||||||
// it will delete the oldler templates if there are exists
|
// it will delete the older templates if there are exists
|
||||||
func UpdateTemplates(ctx *cli.Context) (err error) {
|
func UpdateTemplates(ctx *cli.Context) (err error) {
|
||||||
category := ctx.String("category")
|
category := ctx.String("category")
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
type (
|
type (
|
||||||
// Console wraps from the fmt.Sprintf,
|
// Console wraps from the fmt.Sprintf,
|
||||||
// by default, it implemented the colorConsole to provide the colorful output to the consle
|
// by default, it implemented the colorConsole to provide the colorful output to the console
|
||||||
// and the ideaConsole to output with prefix for the plugin of intellij
|
// and the ideaConsole to output with prefix for the plugin of intellij
|
||||||
Console interface {
|
Console interface {
|
||||||
Success(format string, a ...interface{})
|
Success(format string, a ...interface{})
|
||||||
@@ -81,7 +81,7 @@ func (c *colorConsole) Must(err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewIdeaConsole returns a instace of ideaConsole
|
// NewIdeaConsole returns a instance of ideaConsole
|
||||||
func NewIdeaConsole() Console {
|
func NewIdeaConsole() Console {
|
||||||
return &ideaConsole{}
|
return &ideaConsole{}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func CreateIfNotExist(file string) (*os.File, error) {
|
|||||||
return os.Create(file)
|
return os.Create(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveIfExist deletes the specficed file if it is exists
|
// RemoveIfExist deletes the specified file if it is exists
|
||||||
func RemoveIfExist(filename string) error {
|
func RemoveIfExist(filename string) error {
|
||||||
if !FileExists(filename) {
|
if !FileExists(filename) {
|
||||||
return nil
|
return nil
|
||||||
@@ -36,7 +36,7 @@ func RemoveIfExist(filename string) error {
|
|||||||
return os.Remove(filename)
|
return os.Remove(filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveOrQuit deletes the specficed file if read a permit command from stdin
|
// RemoveOrQuit deletes the specified file if read a permit command from stdin
|
||||||
func RemoveOrQuit(filename string) error {
|
func RemoveOrQuit(filename string) error {
|
||||||
if !FileExists(filename) {
|
if !FileExists(filename) {
|
||||||
return nil
|
return nil
|
||||||
@@ -49,7 +49,7 @@ func RemoveOrQuit(filename string) error {
|
|||||||
return os.Remove(filename)
|
return os.Remove(filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FileExists returns true if the specficed file is exists
|
// FileExists returns true if the specified file is exists
|
||||||
func FileExists(file string) bool {
|
func FileExists(file string) bool {
|
||||||
_, err := os.Stat(file)
|
_, err := os.Stat(file)
|
||||||
return err == nil
|
return err == nil
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ const (
|
|||||||
upper
|
upper
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrNamingFormat defines an error for unknown fomat
|
// ErrNamingFormat defines an error for unknown format
|
||||||
var ErrNamingFormat = errors.New("unsupported format")
|
var ErrNamingFormat = errors.New("unsupported format")
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ func MkdirIfNotExist(dir string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PathFromGoSrc returns the path whihout slash where has been trim the prefix $GOPATH
|
// PathFromGoSrc returns the path without slash where has been trim the prefix $GOPATH
|
||||||
func PathFromGoSrc() (string, error) {
|
func PathFromGoSrc() (string, error) {
|
||||||
dir, err := os.Getwd()
|
dir, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"unicode"
|
"unicode"
|
||||||
)
|
)
|
||||||
|
|
||||||
// String provides for coverting the source text into other spell case,like lower,snake,camel
|
// String provides for converting the source text into other spell case,like lower,snake,camel
|
||||||
type String struct {
|
type String struct {
|
||||||
source string
|
source string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ type DefaultTemplate struct {
|
|||||||
savePath string
|
savePath string
|
||||||
}
|
}
|
||||||
|
|
||||||
// With returns a instace of DefaultTemplate
|
// With returns a instance of DefaultTemplate
|
||||||
func With(name string) *DefaultTemplate {
|
func With(name string) *DefaultTemplate {
|
||||||
return &DefaultTemplate{
|
return &DefaultTemplate{
|
||||||
name: name,
|
name: name,
|
||||||
@@ -30,7 +30,7 @@ func (t *DefaultTemplate) Parse(text string) *DefaultTemplate {
|
|||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
// GoFmt sets the value to goFmt and marks the generated codes will be formated or not
|
// GoFmt sets the value to goFmt and marks the generated codes will be formatted or not
|
||||||
func (t *DefaultTemplate) GoFmt(format bool) *DefaultTemplate {
|
func (t *DefaultTemplate) GoFmt(format bool) *DefaultTemplate {
|
||||||
t.goFmt = format
|
t.goFmt = format
|
||||||
return t
|
return t
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package vars
|
|||||||
const (
|
const (
|
||||||
// ProjectName the const value of zero
|
// ProjectName the const value of zero
|
||||||
ProjectName = "zero"
|
ProjectName = "zero"
|
||||||
// ProjectOpenSourceURL the githb url of go-zero
|
// ProjectOpenSourceURL the github url of go-zero
|
||||||
ProjectOpenSourceURL = "github.com/tal-tech/go-zero"
|
ProjectOpenSourceURL = "github.com/tal-tech/go-zero"
|
||||||
// OsWindows windows os
|
// OsWindows windows os
|
||||||
OsWindows = "windows"
|
OsWindows = "windows"
|
||||||
|
|||||||
Reference in New Issue
Block a user