The cancel-handler goroutine emitted a "watcher stopped" log AFTER setting the watcherStopped flag. Because viper's internal watcher goroutine (started by viper.WatchConfig) has no public Stop and can outlive the context, this log call would race with subsequent zerolog.SetGlobalLevel from the next test's LoadConfig → SetupLogging. Symptom (under go test -race ./pkg/config/...): WARNING: DATA RACE Write at zerolog.SetGlobalLevel Previous read by zerolog.(*Logger).disabled in log.Info(...) Fix: drop the informational log. The flag is sufficient — the cancel ack does not need to be observable. Test cleanups (defer cancel()) already serialize via the t.Cleanup teardown order. Verified: go test -race ./pkg/config/... passes, full BDD suite green.
25 KiB
25 KiB