AJ ONeal bb488fe230 fix(net/ipgate): prevent nil cohort by construction, extract cachedCohortValid
Ensure cohort is never nil:
- NewDomainSet stores an empty Cohort before rebuildCohort, so a parse
  failure leaves an empty (non-nil) cohort instead of nil
- Contains uses CompareAndSwap to lazily self-initialise a zero-value
  struct, making nil impossible after first access — no explicit nil
  check needed

Extract the cache-validity check into a testable cachedCohortValid()
helper and add filesPresent() to detect when data files exist on disk.

Use strings.Builder in commaify() for efficiency.

Tests:
- TestPrefixSetContainsZeroValue: zero-value self-heals via CAS,
  cohort is non-nil after first Contains call
- TestCachedCohortValidRequiresFiles: cache invalidation logic
2026-09-08 20:36:43 -06:00
2026-04-09 14:23:33 -06:00
2026-02-12 00:38:04 -07:00
2025-10-11 19:03:58 -06:00

golib

Go Reference

Sometimes a little copying, sometimes a little dependency. Too small for their own repos.

The default branch is dev, but the stable, versioned tags are based on main.

Also, my Go Cheatsheet:

Description
Sometimes a little copying, sometimes a little dependency, but too small for their own repos.
Readme MPL-2.0 7.4 MiB
Languages
Go 100%