Skip to content

Commit 35cc9b9

Browse files
hs80Copilot
andauthored
Update tools/protoc-gen-go-triple/main.go
移除go_package手动解析 Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 13b53c3 commit 35cc9b9

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

tools/protoc-gen-go-triple/main.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,8 @@ func genTriple(plugin *protogen.Plugin) error {
9191
filename := file.GeneratedFilenamePrefix + ".triple.go"
9292
// Use the same import path as the pb.go file to ensure they're in the same package
9393
// Extract the package name from the go_package option
94-
goPackage := file.Proto.Options.GetGoPackage()
95-
var importPath protogen.GoImportPath
96-
if goPackage != "" {
97-
parts := strings.Split(goPackage, ";")
98-
importPath = protogen.GoImportPath(parts[0])
99-
} else {
100-
importPath = file.GoImportPath
101-
}
102-
g := plugin.NewGeneratedFile(filename, importPath)
94+
// Use the import path as parsed by protogen to avoid edge cases.
95+
g := plugin.NewGeneratedFile(filename, file.GoImportPath)
10396
// 导入dubbo基础库
10497
g.QualifiedGoIdent(protogen.GoImportPath("dubbo.apache.org/dubbo-go/v3/client").Ident("client"))
10598
g.QualifiedGoIdent(protogen.GoImportPath("dubbo.apache.org/dubbo-go/v3/common").Ident("common"))

0 commit comments

Comments
 (0)