From d1129e3974a174e8afc4f4ca01e9ee91966f7565 Mon Sep 17 00:00:00 2001 From: kevin Date: Thu, 3 Sep 2020 10:15:14 +0800 Subject: [PATCH] refactor --- example/shorturl/api/internal/logic/expandlogic.go | 8 ++++---- example/shorturl/api/internal/logic/shortenlogic.go | 8 ++++---- .../shorturl/rpc/transform/internal/logic/expandlogic.go | 4 ++-- .../shorturl/rpc/transform/internal/logic/shortenlogic.go | 4 ++-- tools/goctl/api/gogen/genlogic.go | 4 ++-- tools/goctl/api/parser/util.go | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/example/shorturl/api/internal/logic/expandlogic.go b/example/shorturl/api/internal/logic/expandlogic.go index 83dd0069..52ce0307 100644 --- a/example/shorturl/api/internal/logic/expandlogic.go +++ b/example/shorturl/api/internal/logic/expandlogic.go @@ -10,16 +10,16 @@ import ( ) type ExpandLogic struct { - svcCtx *svc.ServiceContext - ctx context.Context logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext } func NewExpandLogic(ctx context.Context, svcCtx *svc.ServiceContext) ExpandLogic { return ExpandLogic{ - svcCtx: svcCtx, - ctx: ctx, Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, } } diff --git a/example/shorturl/api/internal/logic/shortenlogic.go b/example/shorturl/api/internal/logic/shortenlogic.go index daf42c40..b5e9dcfb 100644 --- a/example/shorturl/api/internal/logic/shortenlogic.go +++ b/example/shorturl/api/internal/logic/shortenlogic.go @@ -10,16 +10,16 @@ import ( ) type ShortenLogic struct { - svcCtx *svc.ServiceContext - ctx context.Context logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext } func NewShortenLogic(ctx context.Context, svcCtx *svc.ServiceContext) ShortenLogic { return ShortenLogic{ - svcCtx: svcCtx, - ctx: ctx, Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, } } diff --git a/example/shorturl/rpc/transform/internal/logic/expandlogic.go b/example/shorturl/rpc/transform/internal/logic/expandlogic.go index 870e307c..528b4f81 100755 --- a/example/shorturl/rpc/transform/internal/logic/expandlogic.go +++ b/example/shorturl/rpc/transform/internal/logic/expandlogic.go @@ -10,16 +10,16 @@ import ( ) type ExpandLogic struct { + logx.Logger ctx context.Context svcCtx *svc.ServiceContext - logx.Logger } func NewExpandLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ExpandLogic { return &ExpandLogic{ + Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx, - Logger: logx.WithContext(ctx), } } diff --git a/example/shorturl/rpc/transform/internal/logic/shortenlogic.go b/example/shorturl/rpc/transform/internal/logic/shortenlogic.go index 2da00849..88f895fe 100755 --- a/example/shorturl/rpc/transform/internal/logic/shortenlogic.go +++ b/example/shorturl/rpc/transform/internal/logic/shortenlogic.go @@ -12,16 +12,16 @@ import ( ) type ShortenLogic struct { + logx.Logger ctx context.Context svcCtx *svc.ServiceContext - logx.Logger } func NewShortenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShortenLogic { return &ShortenLogic{ + Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx, - Logger: logx.WithContext(ctx), } } diff --git a/tools/goctl/api/gogen/genlogic.go b/tools/goctl/api/gogen/genlogic.go index d8f1c4dd..9aa75ea4 100644 --- a/tools/goctl/api/gogen/genlogic.go +++ b/tools/goctl/api/gogen/genlogic.go @@ -20,16 +20,16 @@ import ( ) type {{.logic}} struct { + logx.Logger ctx context.Context svcCtx *svc.ServiceContext - logx.Logger } func New{{.logic}}(ctx context.Context, svcCtx *svc.ServiceContext) {{.logic}} { return {{.logic}}{ + Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx, - Logger: logx.WithContext(ctx), } } diff --git a/tools/goctl/api/parser/util.go b/tools/goctl/api/parser/util.go index 37cbdb18..0d53fd70 100644 --- a/tools/goctl/api/parser/util.go +++ b/tools/goctl/api/parser/util.go @@ -9,7 +9,7 @@ import ( "github.com/tal-tech/go-zero/tools/goctl/api/spec" ) -// struct匹配 +// struct match const typeRegex = `(?m)(?m)(^ *type\s+[a-zA-Z][a-zA-Z0-9_-]+\s+(((struct)\s*?\{[\w\W]*?[^\{]\})|([a-zA-Z][a-zA-Z0-9_-]+)))|(^ *type\s*?\([\w\W]+\}\s*\))` var (