Skip to content

Commit

Permalink
chore: improve template (#161)
Browse files Browse the repository at this point in the history
* chore: improve template

* chore: improve template
  • Loading branch information
qloog authored Nov 20, 2024
1 parent f724eab commit e847aa4
Show file tree
Hide file tree
Showing 17 changed files with 180 additions and 102 deletions.
4 changes: 2 additions & 2 deletions cmd/eagle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

## Go 版本要求

GO >= 1.13
GO >= 1.18

## 脚手架工具获取

Expand All @@ -30,7 +30,7 @@ export GOPROXY=https://mirrors.aliyun.com/goproxy/,direct
下载

```bash
go get -u -v github.com/go-eagle/eagle/cmd/eagle
go install github.com/go-eagle/eagle/cmd/eagle@latest
```

windows:
Expand Down
19 changes: 16 additions & 3 deletions cmd/eagle/go.mod
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
module github.com/go-eagle/eagle/cmd/eagle

go 1.16
go 1.22

require (
github.com/AlecAivazis/survey/v2 v2.2.12
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
github.com/emicklei/proto v1.9.1
github.com/fatih/color v1.9.0
github.com/jedib0t/go-pretty/v6 v6.2.7
github.com/mattn/go-colorable v0.1.6 // indirect
github.com/spf13/cobra v1.1.3
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/mod v0.8.0
)

require (
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/mattn/go-colorable v0.1.6 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/yaml.v3 v3.0.0 // indirect
)
25 changes: 0 additions & 25 deletions cmd/eagle/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
Expand All @@ -212,7 +211,6 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
Expand All @@ -233,7 +231,6 @@ golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand All @@ -250,10 +247,6 @@ golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand All @@ -262,8 +255,6 @@ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180816055513-1c9583448a9c/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand All @@ -283,27 +274,14 @@ golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4=
golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand All @@ -325,9 +303,6 @@ golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
Expand Down
2 changes: 1 addition & 1 deletion cmd/eagle/internal/cache/add/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var (
)

func init() {
CmdAdd.Flags().StringVarP(&targetDir, "-target-dir", "t", "internal/cache", "generate target directory")
CmdAdd.Flags().StringVarP(&targetDir, "-target-dir", "t", "internal/dal/cache", "generate target directory")
}

func run(cmd *cobra.Command, args []string) {
Expand Down
3 changes: 1 addition & 2 deletions cmd/eagle/internal/cache/add/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package add

import (
"fmt"
"io/ioutil"
"os"
"path"

Expand Down Expand Up @@ -41,5 +40,5 @@ func (c *Cache) Generate() error {
if _, err := os.Stat(name); !os.IsNotExist(err) {
return fmt.Errorf("%s already exists", c.Name)
}
return ioutil.WriteFile(name, body, 0644)
return os.WriteFile(name, body, 0644)
}
18 changes: 10 additions & 8 deletions cmd/eagle/internal/cache/add/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
const cacheTemplate = `
package cache
//go:generate mockgen -source=internal/cache/{{.UsName}}_cache.go -destination=internal/mock/{{.UsName}}_cache_mock.go -package mock
//go:generate mockgen -source=internal/dal/cache/{{.UsName}}_cache.go -destination=internal/mock/{{.UsName}}_cache_mock.go -package mock
import (
"context"
Expand All @@ -20,14 +20,15 @@ import (
"github.com/go-eagle/eagle/pkg/cache"
"github.com/go-eagle/eagle/pkg/encoding"
"github.com/go-eagle/eagle/pkg/log"
"github.com/go-eagle/eagle/pkg/redis"
"github.com/go-eagle/eagle/pkg/utils"
"github.com/redis/go-redis/v9"
"{{.ModName}}/internal/model"
"{{.ModName}}/internal/dal/db/model"
)
const (
var (
// Prefix{{.Name}}CacheKey cache prefix
Prefix{{.Name}}CacheKey = "{{.ColonName}}:%d"
Prefix{{.Name}}CacheKey = utils.ConcatString(prefix, "{{.ColonName}}:%d")
)
// {{.Name}}Cache define cache interface
Expand All @@ -37,6 +38,7 @@ type {{.Name}}Cache interface {
MultiGet{{.Name}}Cache(ctx context.Context, ids []int64) (map[string]*model.{{.Name}}Model, error)
MultiSet{{.Name}}Cache(ctx context.Context, data []*model.{{.Name}}Model, duration time.Duration) error
Del{{.Name}}Cache(ctx context.Context, id int64) error
SetCacheWithNotFound(ctx context.Context, id int64) error
}
// {{.LcName}}Cache define cache struct
Expand All @@ -45,11 +47,11 @@ type {{.LcName}}Cache struct {
}
// New{{.Name}}Cache new a cache
func New{{.Name}}Cache() {{.Name}}Cache {
func New{{.Name}}Cache(rdb *redis.Client) {{.Name}}Cache {
jsonEncoding := encoding.JSONEncoding{}
cachePrefix := ""
return &{{.LcName}}Cache{
cache: cache.NewRedisCache(redis.RedisClient, cachePrefix, jsonEncoding, func() interface{} {
cache: cache.NewRedisCache(rdb, cachePrefix, jsonEncoding, func() interface{} {
return &model.{{.Name}}Model{}
}),
}
Expand Down Expand Up @@ -78,7 +80,7 @@ func (c *{{.LcName}}Cache) Get{{.Name}}Cache(ctx context.Context, id int64) (dat
cacheKey := c.Get{{.Name}}CacheKey(id)
err = c.cache.Get(ctx, cacheKey, &data)
if err != nil {
log.WithContext(ctx).Warnf("get err from redis, err: %+v", err)
log.WithContext(ctx).Warnf("[cache] Get{{.Name}}Cache err from redis, err: %+v", err)
return nil, err
}
return data, nil
Expand Down
6 changes: 3 additions & 3 deletions cmd/eagle/internal/handler/add/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package add
import (
"fmt"

"github.com/go-eagle/eagle/cmd/eagle/internal/utils"

"github.com/spf13/cobra"

"github.com/go-eagle/eagle/cmd/eagle/internal/utils"
)

// CmdCache represents the new command.
Expand All @@ -25,7 +25,7 @@ var (
func init() {
CmdAdd.Flags().StringVarP(&targetDir, "target-dir", "t", "internal/handler", "generate target directory")
CmdAdd.Flags().StringVarP(&version, "version", "v", "v1", "handler version")
CmdAdd.Flags().StringVarP(&method, "method", "m", "get", "http method")
CmdAdd.Flags().StringVarP(&method, "method", "m", "GET", "http method, eg: GET, POST, PUT, PATCH, DELETE")
}

func run(cmd *cobra.Command, args []string) {
Expand Down
3 changes: 1 addition & 2 deletions cmd/eagle/internal/handler/add/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package add

import (
"fmt"
"io/ioutil"
"os"
"path"

Expand Down Expand Up @@ -39,5 +38,5 @@ func (h *Handler) Generate() error {
if _, err := os.Stat(name); !os.IsNotExist(err) {
return fmt.Errorf("%s already exists", h.Name)
}
return ioutil.WriteFile(name, body, 0644)
return os.WriteFile(name, body, 0644)
}
50 changes: 48 additions & 2 deletions cmd/eagle/internal/handler/add/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ package v1
import (
"github.com/gin-gonic/gin"
"github.com/go-eagle/eagle/pkg/app"
"github.com/go-eagle/eagle/pkg/errcode"
"github.com/go-eagle/eagle-layout/internal/service"
"github.com/go-eagle/eagle-layout/internal/types"
)
// {{.Name}} {{.LcName}}
Expand All @@ -23,9 +27,51 @@ import (
// @Produce json
// @Router /{{.UsName}} {{.Method}}
func {{.Name}}(c *gin.Context) {
// here add your code
var req types.{{.Name}}Request
{{- if .Method eq "GET" }}
if err := c.ShouldBindQuery(&req); err != nil {
app.Error(c, errcode.ErrInvalidParam.WithDetails(err.Error()))
return
}
{{- end }}
{{- if .Method eq "POST" }}
if err := c.ShouldBindJSON(&req); err != nil {
app.Error(c, errcode.ErrInvalidParam.WithDetails(err.Error()))
return
}
{{- end }}
{{- if .Method eq "PUT" }}
if err := c.ShouldBindJSON(&req); err != nil {
app.Error(c, errcode.ErrInvalidParam.WithDetails(err.Error()))
return
}
{{- end }}
{{- if .Method eq "PATCH" }}
if err := c.ShouldBindJSON(&req); err != nil {
app.Error(c, errcode.ErrInvalidParam.WithDetails(err.Error()))
return
}
{{- end }}
{{- if .Method eq "DELETE" }}
if err := c.ShouldBindJSON(&req); err != nil {
app.Error(c, errcode.ErrInvalidParam.WithDetails(err.Error()))
return
}
{{- end }}
var ret any
// change to your service
// ret, err := service.GreeterSvc.Hello(c, req.Name)
// if err != nil {
// app.Error(c, err)
// return
// }
app.Success(c, gin.H{})
app.Success(c, ret)
}
`

Expand Down
2 changes: 1 addition & 1 deletion cmd/eagle/internal/proto/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func run(cmd *cobra.Command, args []string) {
}
for _, s := range res {
serviceName := strings.Replace(strings.ToLower(s.Service), "service", "", 1)
to := path.Join(targetDir, serviceName+"_svc.go")
to := path.Join(targetDir, serviceName+"_grpc_svc.go")
if _, err := os.Stat(to); !os.IsNotExist(err) {
fmt.Fprintf(os.Stderr, "%s already exists: %s\n", s.Service, to)
continue
Expand Down
3 changes: 1 addition & 2 deletions cmd/eagle/internal/repo/add/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package add

import (
"fmt"
"io/ioutil"
"os"
"path"

Expand Down Expand Up @@ -41,5 +40,5 @@ func (r *Repo) Generate() error {
if _, err := os.Stat(name); !os.IsNotExist(err) {
return fmt.Errorf("%s already exists", r.Name)
}
return ioutil.WriteFile(name, body, 0644)
return os.WriteFile(name, body, 0644)
}
Loading

0 comments on commit e847aa4

Please sign in to comment.