You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
725 B
Go
44 lines
725 B
Go
4 years ago
|
package gogen
|
||
|
|
||
|
import (
|
||
|
"github.com/tal-tech/go-zero/tools/goctl/util"
|
||
|
"github.com/tal-tech/go-zero/tools/goctl/util/console"
|
||
|
)
|
||
|
|
||
4 years ago
|
const rpcTemplateText = `syntax = "proto3";
|
||
4 years ago
|
|
||
4 years ago
|
package remote;
|
||
4 years ago
|
|
||
|
message Request {
|
||
|
string username = 1;
|
||
|
string password = 2;
|
||
|
}
|
||
|
|
||
|
message Response {
|
||
|
string name = 1;
|
||
|
string gender = 2;
|
||
|
}
|
||
|
|
||
4 years ago
|
service User {
|
||
|
rpc Login(Request) returns(Response);
|
||
|
}
|
||
|
`
|
||
4 years ago
|
|
||
4 years ago
|
type rpcTemplate struct {
|
||
|
out string
|
||
|
console.Console
|
||
|
}
|
||
4 years ago
|
|
||
|
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.")
|
||
|
}
|