mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-14 18:30:02 +08:00
rpc service generation (#26)
* add execute files * add protoc-osx * add rpc generation * add rpc generation * add: rpc template generation * update usage * fixed env prepare for project in go path * optimize gomod cache * add README.md * format error * reactor templatex.go * remove waste code
This commit is contained in:
44
tools/goctl/rpc/goen/template.go
Normal file
44
tools/goctl/rpc/goen/template.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package gogen
|
||||
|
||||
import (
|
||||
"github.com/tal-tech/go-zero/tools/goctl/util"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/util/console"
|
||||
)
|
||||
|
||||
var rpcTemplateText = `syntax = "proto3";
|
||||
|
||||
package remoteuser;
|
||||
|
||||
message Request {
|
||||
string username = 1;
|
||||
string password = 2;
|
||||
}
|
||||
|
||||
message Response {
|
||||
string name = 1;
|
||||
string gender = 2;
|
||||
}
|
||||
|
||||
service User{
|
||||
rpc Login(Request)returns(Response);
|
||||
}`
|
||||
|
||||
type (
|
||||
rpcTemplate struct {
|
||||
out string
|
||||
console.Console
|
||||
}
|
||||
)
|
||||
|
||||
func NewRpcTemplate(out string, idea bool) *rpcTemplate {
|
||||
return &rpcTemplate{
|
||||
out: out,
|
||||
Console: console.NewConsole(idea),
|
||||
}
|
||||
}
|
||||
|
||||
func (r *rpcTemplate) MustGenerate() {
|
||||
err := util.With("t").Parse(rpcTemplateText).SaveTo(nil, r.out, false)
|
||||
r.Must(err)
|
||||
r.Success("Done.")
|
||||
}
|
||||
Reference in New Issue
Block a user