aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/index/index.go
diff options
context:
space:
mode:
authorJP Appel <jeanpierre.appel01@gmail.com>2025-07-22 15:41:03 -0400
committerJP Appel <jeanpierre.appel01@gmail.com>2025-07-22 15:41:03 -0400
commit344c6526a8d6f490fc7628ddc7d2dd06ed1a07c1 (patch)
tree342878ff5d77b557533d6e5473e1d8f6e79ac6e9 /pkg/index/index.go
parentfaf35ef54885bc48b897508ce3cb40b868ff505b (diff)
Separate program entry point from commands
Diffstat (limited to 'pkg/index/index.go')
-rw-r--r--pkg/index/index.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/pkg/index/index.go b/pkg/index/index.go
index cfa4138..50f642e 100644
--- a/pkg/index/index.go
+++ b/pkg/index/index.go
@@ -12,6 +12,7 @@ import (
"slices"
"strings"
"sync"
+ "sync/atomic"
"time"
"github.com/goccy/go-yaml"
@@ -383,21 +384,23 @@ func ParseDoc(path string, opts ParseOpts) (*Document, error) {
return doc, nil
}
-func ParseDocs(paths []string, numWorkers uint, opts ParseOpts) map[string]*Document {
+func ParseDocs(paths []string, numWorkers uint, opts ParseOpts) (map[string]*Document, uint64) {
jobs := make(chan string, numWorkers)
results := make(chan *Document, numWorkers)
docs := make(map[string]*Document, len(paths))
wg := &sync.WaitGroup{}
+ errCnt := &atomic.Uint64{}
wg.Add(int(numWorkers))
for range numWorkers {
go func(jobs <-chan string, results chan<- *Document, wg *sync.WaitGroup) {
for path := range jobs {
doc, err := ParseDoc(path, opts)
if err != nil {
- slog.Error("Error occured while parsing file",
+ slog.Warn("Error occured while parsing file",
slog.String("path", path), slog.String("err", err.Error()),
)
+ errCnt.Add(1)
continue
}
@@ -423,7 +426,7 @@ func ParseDocs(paths []string, numWorkers uint, opts ParseOpts) map[string]*Docu
docs[doc.Path] = doc
}
- return docs
+ return docs, errCnt.Load()
}
func init() {