chore: coding style for quickstart (#1902)

This commit is contained in:
Kevin Wan
2022-05-13 23:10:55 +08:00
committed by GitHub
parent e567a0c718
commit c6e2b4a43a
3 changed files with 33 additions and 33 deletions

View File

@@ -15,10 +15,10 @@ func main() {
var c config.Config var c config.Config
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
ctx := svc.NewServiceContext(c)
server := rest.MustNewServer(c.RestConf) server := rest.MustNewServer(c.RestConf)
defer server.Stop() defer server.Stop()
ctx := svc.NewServiceContext(c)
handler.RegisterHandlers(server, ctx) handler.RegisterHandlers(server, ctx)
fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port) fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)

View File

@@ -5,9 +5,8 @@ import (
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
"greet/api/internal/svc" "greet/api/internal/svc"
"greet/api/internal/types" "greet/api/internal/types"{{if .callRPC}}
{{if .callRPC}}"greet/rpc/greet" "greet/rpc/greet"{{end}}
{{end}}
) )
type PingLogic struct { type PingLogic struct {
@@ -25,10 +24,11 @@ func NewPingLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PingLogic {
} }
func (l *PingLogic) Ping() (resp *types.Resp, err error) { func (l *PingLogic) Ping() (resp *types.Resp, err error) {
{{if .callRPC}}if _, err = l.svcCtx.GreetRpc.Ping(l.ctx, &greet.Placeholder{});err !=nil { {{if .callRPC}}if _, err = l.svcCtx.GreetRpc.Ping(l.ctx, new(greet.Placeholder)); err != nil {
return return
}{{end}} }
resp = new(types.Resp)
{{end}}resp = new(types.Resp)
resp.Msg = "pong" resp.Msg = "pong"
return return