func Slice(tagsPerFile int, dstdir string, srcdirs []string) error {
var infiles []string
for _, srcdir := range srcdirs {
- files, err := allGobFiles(srcdir)
+ files, err := allFiles(srcdir, matchGobFile)
if err != nil {
return err
}
throttle := throttle{Max: runtime.GOMAXPROCS(0)}
for _, infile := range infiles {
infile := infile
- throttle.Acquire()
- go func() {
- defer throttle.Release()
+ throttle.Go(func() error {
f, err := open(infile)
if err != nil {
- throttle.Report(err)
- return
+ return err
}
defer f.Close()
dir, _ := filepath.Split(infile)
namespace := dirNamespace[dir]
log.Printf("reading %s (namespace %d)", infile, namespace)
- err = DecodeLibrary(f, strings.HasSuffix(infile, ".gz"), func(ent *LibraryEntry) error {
+ return DecodeLibrary(f, strings.HasSuffix(infile, ".gz"), func(ent *LibraryEntry) error {
if err := throttle.Err(); err != nil {
return err
}
}
return nil
})
- throttle.Report(err)
- }()
+ })
}
throttle.Wait()
if throttle.Err() != nil {