From cf33aae91d628e25174259fdf0045e2a1457f778 Mon Sep 17 00:00:00 2001 From: kingxt Date: Thu, 22 Oct 2020 22:19:06 +0800 Subject: [PATCH] ignore blank between bracket and service tag (#154) * rebase upstream * rebase * trim no need line * trim no need line * trim no need line * update doc * remove update * remove no need * remove no need * goctl add jwt support * goctl add jwt support * goctl add jwt support * goctl support import * goctl support import * support return () * revert * refactor and rename folder to group * remove no need * add anonymous annotation * optimized * rename * rename * update test * api add middleware support: usage: @server( middleware: M1, M2 ) * api add middleware support: usage: @server( middleware: M1, M2 ) * simple logic * optimized * optimized generator formatted code * optimized generator formatted code * add more test * ignore black between bracket and service tag * use join instead * format Co-authored-by: kingxt --- tools/goctl/api/parser/util.go | 2 +- tools/goctl/configgen/genconfig.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/goctl/api/parser/util.go b/tools/goctl/api/parser/util.go index 63b6caf4..d318caa5 100644 --- a/tools/goctl/api/parser/util.go +++ b/tools/goctl/api/parser/util.go @@ -133,7 +133,7 @@ func isTypeBeginLine(line string) bool { } func isServiceBeginLine(line string) bool { - return strings.HasPrefix(line, "@server(") || (strings.HasPrefix(line, "service") && strings.HasSuffix(line, "{")) + return strings.HasPrefix(line, "@server") || (strings.HasPrefix(line, "service") && strings.HasSuffix(line, "{")) } func lineBeginOfService(api string) int { diff --git a/tools/goctl/configgen/genconfig.go b/tools/goctl/configgen/genconfig.go index 6aae2bae..31ce9246 100644 --- a/tools/goctl/configgen/genconfig.go +++ b/tools/goctl/configgen/genconfig.go @@ -42,12 +42,14 @@ func GenConfigCommand(c *cli.Context) error { if err != nil { return errors.New("abs failed: " + c.String("path")) } + goModPath, hasFound := util.FindGoModPath(path) if !hasFound { return errors.New("go mod not initial") } + path = strings.TrimSuffix(path, "/config.go") - location := path + "/tmp" + location := filepath.Join(path, "tmp") err = os.MkdirAll(location, os.ModePerm) if err != nil { return err @@ -76,10 +78,12 @@ func GenConfigCommand(c *cli.Context) error { if err != nil { panic(err) } + path, err = os.Getwd() if err != nil { panic(err) } + err = os.Rename(filepath.Dir(goPath)+"/config.yaml", path+"/config.yaml") if err != nil { panic(err)