Skip to content

Commit

Permalink
fix: correctly handle wkt import paths
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Stewart <[email protected]>
  • Loading branch information
paralin committed May 16, 2024
1 parent 5607d8a commit 3d338c7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions compiler/protogen/protogen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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])
Expand Down

0 comments on commit 3d338c7

Please sign in to comment.