diff --git a/protogen/protogen.go b/protogen/protogen.go index 4e76c307..0ad54205 100644 --- a/protogen/protogen.go +++ b/protogen/protogen.go @@ -275,6 +275,11 @@ func New(req *pluginpb.CodeGeneratorRequest, opts *Options) (*Plugin, error) { // the same Go package name. packageFiles := make(map[GoImportPath][]string) for filename, importPath := range importPaths { + if _, ok := packageNames[filename]; !ok { + // Skip files mentioned in a M= parameter + // but which do not appear in the CodeGeneratorRequest. + continue + } packageFiles[importPath] = append(packageFiles[importPath], filename) } for importPath, filenames := range packageFiles {