fix: quickstart wrong package when go.mod exists in parent dir (#2048)
* chore: fix typo * fix: quickstart in dir with go.mod * fix: runner failed * chore: refine code * chore: simplify quickstart mono
This commit is contained in:
@@ -4,9 +4,10 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"greet/api/internal/svc"
|
||||
"greet/api/internal/types"{{if .callRPC}}
|
||||
"greet/rpc/greet"{{end}}
|
||||
|
||||
"{{.svcPkg}}"
|
||||
"{{.typesPkg}}"{{if .callRPC}}
|
||||
"{{.rpcClientPkg}}"{{end}}
|
||||
)
|
||||
|
||||
type PingLogic struct {
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
package svc
|
||||
|
||||
import (
|
||||
"{{.configPkg}}"{{if .callRPC}}
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
"greet/api/internal/config"
|
||||
"greet/rpc/greet"
|
||||
"{{.rpcClientPkg}}"{{end}}
|
||||
)
|
||||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
GreetRpc greet.Greet
|
||||
Config config.Config{{if .callRPC}}
|
||||
GreetRpc greet.Greet{{end}}
|
||||
}
|
||||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
client := zrpc.MustNewClient(zrpc.RpcClientConf{
|
||||
{{if .callRPC}}client := zrpc.MustNewClient(zrpc.RpcClientConf{
|
||||
Target: "127.0.0.1:8080",
|
||||
})
|
||||
}){{end}}
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
GreetRpc: greet.NewGreet(client),
|
||||
{{if .callRPC}}GreetRpc: greet.NewGreet(client),{{end}}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user