Support .proto files

This commit is contained in:
Fedor Korotkiy 2023-04-19 00:28:09 +04:00
parent 48d46ea578
commit 5c8dd14d7e

View file

@ -1,8 +1,11 @@
package commands package commands
import ( import (
"bytes"
"io/fs"
"log" "log"
"os" "os"
"path/filepath"
"sort" "sort"
"strings" "strings"
@ -84,6 +87,28 @@ func listPrivateFiles(rootPackage string) []string {
} }
} }
if err := filepath.WalkDir(rootPackage, func(path string, d fs.DirEntry, err error) error {
if strings.HasSuffix(path, ".proto") {
content, err := os.ReadFile(path)
if err != nil {
return err
}
if bytes.Contains(content, []byte("//go:build solution")) {
absPath, err := filepath.Abs(path)
if err != nil {
return err
}
files = append(files, absPath)
}
}
return nil
}); err != nil {
log.Fatalf("filewalk failed: %v", err)
}
sort.Strings(files) sort.Strings(files)
return files return files
} }