Compare commits

...

3 Commits

Author SHA1 Message Date
9c05b6b646 Merge pull request 'fix gen' (#89) from fixu into v3
Reviewed-on: #89
2023-12-26 00:56:08 +03:00
675ca27dbf fix gen
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-12-26 00:55:09 +03:00
f22d8ed055 error generate in standalone mode
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-10-18 01:02:05 +03:00
2 changed files with 15 additions and 8 deletions

View File

@@ -90,6 +90,9 @@ func (g *Generator) Generate(plugin *protogen.Plugin) error {
continue
case "micro":
err = g.microGenerate(component, plugin, genClient, genServer)
if err == nil {
err = g.writeErrors(plugin)
}
case "http":
err = g.httpGenerate(component, plugin, genClient, genServer)
case "grpc", "drpc", "rpc":
@@ -113,11 +116,6 @@ func (g *Generator) Generate(plugin *protogen.Plugin) error {
}
if err = g.writeErrors(plugin); err != nil {
plugin.Error(err)
return err
}
if err = g.astGenerate(plugin); err != nil {
plugin.Error(err)
return err

15
util.go
View File

@@ -572,7 +572,7 @@ func (g *Generator) generateClientFuncSignature(gfile *protogen.GeneratedFile, s
if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
args = append(args, "*", gfile.QualifiedGoIdent(method.Output.GoIdent))
} else {
args = append(args, serviceName, "_", method.GoName, "Client")
args = append(args, gfile.QualifiedGoIdent(protogen.GoIdent{GoName: serviceName + "_" + method.GoName + "Client", GoImportPath: method.Output.GoIdent.GoImportPath}))
}
args = append(args, ", error) {")
gfile.P(args...)
@@ -657,7 +657,7 @@ func (g *Generator) generateServiceServerStreamInterface(gfile *protogen.Generat
gfile.P("RecvMsg(msg interface{}) error")
if method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
gfile.P("SendAndClose(msg *", gfile.QualifiedGoIdent(method.Output.GoIdent), ") error")
gfile.P("CloseSend() error")
// gfile.P("CloseSend() error")
}
gfile.P("Close() error")
if method.Desc.IsStreamingClient() {
@@ -968,8 +968,10 @@ func (g *Generator) writeErrors(plugin *protogen.Plugin) error {
}
var gfile *protogen.GeneratedFile
var importPath protogen.GoImportPath
if len(errorsMap) > 0 {
gfile = plugin.NewGeneratedFile("micro_errors.pb.go", ".")
var packageName string
for _, file := range plugin.Files {
@@ -980,9 +982,16 @@ func (g *Generator) writeErrors(plugin *protogen.Plugin) error {
continue
}
packageName = string(file.GoPackageName)
importPath = file.GoImportPath
break
}
if g.standalone {
importPath = "."
}
gfile = plugin.NewGeneratedFile("micro_errors.pb.go", importPath)
gfile.P("// Code generated by protoc-gen-go-micro. DO NOT EDIT.")
gfile.P("// protoc-gen-go-micro version: " + versionComment)
gfile.P()