Documentation
¶
Overview ¶
Package geo resolves visitor IPs to a country code using the DB-IP Lite free database (db-ip.com, CC BY 4.0 — the dashboard credits it wherever countries render). Chosen over MaxMind because the download needs no account or key.
Design constraints, in order: (1) privacy — the IP is used for one in-memory lookup at ingest and never stored; only the ISO country code is stamped on the event. (2) zero dependencies — the CSV edition parses with the stdlib into a sorted range table (~600k IPv4 ranges ≈ 12MB resident), no mmdb reader needed. (3) never block serving — Open returns immediately and loads (downloading the ~10MB file on first boot) in the background; lookups before readiness return "" and events simply carry no country, exactly like a backend event would.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
func Open ¶
Open returns a resolver immediately and loads path in the background. If the file is missing it is downloaded from DB-IP first (month-stamped URL, falling back to the previous month around release day). Any failure logs once and leaves the resolver empty — geo is an enrichment, never a dependency.