From 3d338c71aeae64883629889fe623a65c20c5737c Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Wed, 15 May 2024 22:29:32 -0700 Subject: [PATCH] fix: correctly handle wkt import paths Signed-off-by: Christian Stewart --- compiler/protogen/protogen.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/protogen/protogen.go b/compiler/protogen/protogen.go index 12612b27..b7068cef 100644 --- a/compiler/protogen/protogen.go +++ b/compiler/protogen/protogen.go @@ -58,6 +58,9 @@ func init() { if envPkg := os.Getenv("PROTOBUF_GO_TYPES_PKG"); envPkg != "" { typesPackage = envPkg } + if !strings.HasSuffix(typesPackage, "/") { + typesPackage += "/" + } } // Run executes a function as a protoc plugin. @@ -1075,10 +1078,12 @@ func (g *GeneratedFile) Content() ([]byte, error) { // Collect a sorted list of all imports. var importPaths [][2]string rewriteImport := func(importPath string) string { + goImportPath := GoImportPath(importPath) + goImportPath = fixTypesPrefix(goImportPath) if f := g.gen.opts.ImportRewriteFunc; f != nil { - return string(f(GoImportPath(importPath))) + return string(f(goImportPath)) } - return importPath + return string(goImportPath) } for importPath := range g.packageNames { pkgName := string(g.packageNames[importPath])