Summary
build.sh runs go test -cover -v ./... but does not pass -race. Given the heavy use of goroutines without synchronization (File.Info() lazily caches info, WalkDir fans out unbounded), a race detector run is very likely to find issues. The lazy cache in particular:
func (f *File) Info() os.FileInfo {
if f.info == nil {
stat, err := os.Stat(f.Path)
...
f.info = stat
}
return f.info
}
is not safe if a single *File is shared across goroutines (currently each *File is owned by one goroutine, but the invariant is fragile).
Suggested Fix
- Add
-race to the test command in build.sh.
- Optionally also run
go vet (already done) and staticcheck in CI.
Files
Summary
build.shrunsgo test -cover -v ./...but does not pass-race. Given the heavy use of goroutines without synchronization (File.Info()lazily cachesinfo,WalkDirfans out unbounded), a race detector run is very likely to find issues. The lazy cache in particular:is not safe if a single
*Fileis shared across goroutines (currently each*Fileis owned by one goroutine, but the invariant is fragile).Suggested Fix
-raceto the test command inbuild.sh.go vet(already done) andstaticcheckin CI.Files
build.sh:31