Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions cmd/protogen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
package main

import (
"bufio"
"bytes"
"context"
"errors"
Expand Down Expand Up @@ -119,9 +120,12 @@ func findEnums(ctx context.Context, cfg genConfig) ([]string, []string, error) {
if err != nil {
return err
}
matches := enumRgx.FindAllStringSubmatch(string(bs), -1)
for i := 0; i < len(matches); i++ {
enums = append(enums, matches[i][1])
scanner := bufio.NewScanner(bytes.NewReader(bs))
for scanner.Scan() {
Comment on lines +123 to +124
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you help me understand the situation where the previous code didn't work? (not that I disagree w/ the change, just trying to understand)

matches := enumRgx.FindAllStringSubmatch(scanner.Text(), -1)
for i := 0; i < len(matches); i++ {
enums = append(enums, matches[i][1])
}
}
return nil
}
Expand Down Expand Up @@ -155,7 +159,7 @@ func runProtoc(ctx context.Context, cfg genConfig, protoDirs []string) error {
for _, plugin := range cfg.plugins {
args = append(args, fmt.Sprintf("--%s", plugin))
}
files, err := filepath.Glob(filepath.Join(dir, "*"))
files, err := filepath.Glob(filepath.Join(dir, "*.proto"))
if err != nil {
return err
}
Expand Down
Loading