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
import (
"bytes"
"io/fs"
"log"
"os"
"path/filepath"
"sort"
"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)
return files
}