Skip to content

Commit af18b82

Browse files
authored
fix pb type (#57)
1 parent dc12759 commit af18b82

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

cmds/protoc-gen-lava/internal/gen.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,11 @@ func GenerateFile(gen *protogen.Plugin, file *protogen.File) (g *protogen.Genera
7373
keyPrefix := strings.ReplaceAll(srvInfo.GoName, "InnerService", "")
7474
keyPrefix = strings.ReplaceAll(keyPrefix, "Inner", "") + "Service"
7575

76-
var pbPkg = ""
77-
if file.GoImportPath != meta.mth.Input.GoIdent.GoImportPath {
78-
pbPkg = string(meta.mth.Input.GoIdent.GoImportPath)
79-
}
80-
8176
genFile.Var().Op("_").Op("=").Qual(rpcMetaPkg, "Register").Call(
8277
jen.Op("&").Qual(rpcMetaPkg, "RpcMeta").Values(
8378
jen.Dict{
84-
jen.Id("Input"): jen.New(jen.Qual(pbPkg, meta.mth.Input.GoIdent.GoName)),
85-
jen.Id("Output"): jen.New(jen.Qual(pbPkg, meta.mth.Output.GoIdent.GoName)),
79+
jen.Id("Input"): jen.New(getPkg(file, meta.mth.Input.GoIdent)),
80+
jen.Id("Output"): jen.New(getPkg(file, meta.mth.Output.GoIdent)),
8681
jen.Id("Name"): jen.Lit(meta.meta.Name),
8782
jen.Id("Method"): jen.Lit(fmt.Sprintf("%s/%s", meta.srv.Desc.FullName(), meta.mth.GoName)),
8883
jen.Id("Tags"): jen.Map(jen.String()).String().Values(
@@ -99,3 +94,12 @@ func GenerateFile(gen *protogen.Plugin, file *protogen.File) (g *protogen.Genera
9994
g.P(genFile.GoString())
10095
return g
10196
}
97+
98+
func getPkg(file *protogen.File, goIdent protogen.GoIdent) *jen.Statement {
99+
var pkgName = ""
100+
if file.GoImportPath != goIdent.GoImportPath {
101+
pkgName = string(goIdent.GoImportPath)
102+
}
103+
104+
return jen.Qual(pkgName, goIdent.GoName)
105+
}

cmds/protoc-gen-lava/internal/version.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package internal
22

33
import (
44
"fmt"
5-
5+
66
"google.golang.org/protobuf/compiler/protogen"
77
)
88

9-
const Version = "v0.0.2"
9+
const Version = "v0.0.3"
1010

1111
func protocVersion(gen *protogen.Plugin) string {
1212
v := gen.Request.GetCompilerVersion()

0 commit comments

Comments
 (0)