Skip to content

Commit

Permalink
Update plugin.go
Browse files Browse the repository at this point in the history
  • Loading branch information
loveyana committed Dec 12, 2023
1 parent 9413084 commit f62a50f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/hz/protobuf/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,11 @@ func (plugin *Plugin) GenerateFiles(pluginPb *protogen.Plugin) error {
func (plugin *Plugin) GenerateFile(gen *protogen.Plugin, f *protogen.File) error {
impt := string(f.GoImportPath)
if strings.HasPrefix(impt, plugin.Package) {
impt = impt[len(plugin.Package)+1:]
impt = impt[len(plugin.Package):]
}
// The file name must be the relative path, reference https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/compiler/plugin.proto#L122
if strings.HasPrefix(impt, "/") {
impt = impt[1:]
}
f.GeneratedFilenamePrefix = filepath.Join(util.ImportToPath(impt, ""), util.BaseName(f.Proto.GetName(), ".proto"))
f.Generate = true
Expand Down

0 comments on commit f62a50f

Please sign in to comment.