* 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
45 lines
732 B
Go
45 lines
732 B
Go
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.")
|
|
}
|