mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-24 01:30:25 +08:00
555c4ecd1a
* chore: fix typo * fix: quickstart in dir with go.mod * fix: runner failed * chore: refine code * chore: simplify quickstart mono
23 lines
488 B
Smarty
23 lines
488 B
Smarty
package svc
|
|
|
|
import (
|
|
"{{.configPkg}}"{{if .callRPC}}
|
|
"github.com/zeromicro/go-zero/zrpc"
|
|
"{{.rpcClientPkg}}"{{end}}
|
|
)
|
|
|
|
type ServiceContext struct {
|
|
Config config.Config{{if .callRPC}}
|
|
GreetRpc greet.Greet{{end}}
|
|
}
|
|
|
|
func NewServiceContext(c config.Config) *ServiceContext {
|
|
{{if .callRPC}}client := zrpc.MustNewClient(zrpc.RpcClientConf{
|
|
Target: "127.0.0.1:8080",
|
|
}){{end}}
|
|
return &ServiceContext{
|
|
Config: c,
|
|
{{if .callRPC}}GreetRpc: greet.NewGreet(client),{{end}}
|
|
}
|
|
}
|