From 89fbb1fec71edec0da52149aa7cdf153fa09a757 Mon Sep 17 00:00:00 2001 From: Abhinav Nekkanti <10552725+anekkanti@users.noreply.github.com> Date: Mon, 25 Nov 2024 11:04:25 -0800 Subject: [PATCH] Fix for protogen cmd --- cmd/protogen/main.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/protogen/main.go b/cmd/protogen/main.go index 8b557395..03397162 100644 --- a/cmd/protogen/main.go +++ b/cmd/protogen/main.go @@ -23,6 +23,7 @@ package main import ( + "bufio" "bytes" "context" "errors" @@ -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() { + matches := enumRgx.FindAllStringSubmatch(scanner.Text(), -1) + for i := 0; i < len(matches); i++ { + enums = append(enums, matches[i][1]) + } } return nil } @@ -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 }