go-zero/tools/goctl/quickstart/idl/svc.tpl
anqiansong 52f060caae
feat: Add goctl quickstart (#1889)
* Add goctl quickstart

* Format code

* Format code
2022-05-13 12:23:24 +08:00

23 lines
454 B
Smarty

package svc
import (
"github.com/zeromicro/go-zero/zrpc"
"greet/api/internal/config"
"greet/rpc/greet"
)
type ServiceContext struct {
Config config.Config
GreetRpc greet.Greet
}
func NewServiceContext(c config.Config) *ServiceContext {
client := zrpc.MustNewClient(zrpc.RpcClientConf{
Target: "127.0.0.1:8080",
})
return &ServiceContext{
Config: c,
GreetRpc: greet.NewGreet(client),
}
}