Proper synchronization.

main
Nick Dumas 2 years ago
parent b91c1ebf6e
commit aedc41a021

@ -6,6 +6,7 @@ import (
"io/fs" "io/fs"
"os" "os"
"strings" "strings"
"sync"
"go.uber.org/zap" "go.uber.org/zap"
@ -42,7 +43,10 @@ func main() {
return nil return nil
} }
var wg sync.WaitGroup
go func() { go func() {
defer wg.Done()
wg.Add(1)
for fn := range fileNames { for fn := range fileNames {
if !strings.HasSuffix(fn, ".md") { if !strings.HasSuffix(fn, ".md") {
continue continue
@ -61,5 +65,7 @@ func main() {
if err != nil { if err != nil {
l.Fatal("error walking for files", zap.Error(err)) l.Fatal("error walking for files", zap.Error(err))
} }
close(fileNames)
wg.Wait()
} }

Loading…
Cancel
Save