fc1aa09a20
Rule.matcher was lazily compiled and cached in matchPattern with no synchronisation. applyCoverageDomains matches files across goroutines against one shared []Rule (MatchFile takes &rules[i]), so concurrent first calls raced on r.matcher and on the half-published GitIgnore — go test -race flagged it at parser.go:35/36. Parse now precompiles rule.matcher in its single goroutine; matchPattern is read-only (returns the cached matcher, or a throwaway compile for a Rule built outside Parse) and never writes the field, so the concurrent MatchFile hot path only reads. No lock is added — Rule is a value type copied by append, which would trip copylocks. Cost is negligible: a CODEOWNERS file is small and compiled once per file, not per source file. parser_race_test.go drives 64 goroutines x MatchFile over a shared rule list; pre-fix it tripped the race detector, clean after.