@@ -73,16 +73,11 @@ func GenerateFile(gen *protogen.Plugin, file *protogen.File) (g *protogen.Genera
73
73
keyPrefix := strings .ReplaceAll (srvInfo .GoName , "InnerService" , "" )
74
74
keyPrefix = strings .ReplaceAll (keyPrefix , "Inner" , "" ) + "Service"
75
75
76
- var pbPkg = ""
77
- if file .GoImportPath != meta .mth .Input .GoIdent .GoImportPath {
78
- pbPkg = string (meta .mth .Input .GoIdent .GoImportPath )
79
- }
80
-
81
76
genFile .Var ().Op ("_" ).Op ("=" ).Qual (rpcMetaPkg , "Register" ).Call (
82
77
jen .Op ("&" ).Qual (rpcMetaPkg , "RpcMeta" ).Values (
83
78
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 )),
86
81
jen .Id ("Name" ): jen .Lit (meta .meta .Name ),
87
82
jen .Id ("Method" ): jen .Lit (fmt .Sprintf ("%s/%s" , meta .srv .Desc .FullName (), meta .mth .GoName )),
88
83
jen .Id ("Tags" ): jen .Map (jen .String ()).String ().Values (
@@ -99,3 +94,12 @@ func GenerateFile(gen *protogen.Plugin, file *protogen.File) (g *protogen.Genera
99
94
g .P (genFile .GoString ())
100
95
return g
101
96
}
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
+ }
0 commit comments