Skip to content

Tests do not run with -race; data-race-prone code is not detected #12

@dolph

Description

@dolph

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

  • build.sh:31

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions