Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Entry ¶
type Entry struct {
CountryCode string // ISO 3166-1 alpha-2, e.g. "US"
ZipCode string
City string
State string // full name, e.g. "California"
StateCode string // abbreviation, e.g. "CA"
Lat float64
Lon float64
}
Entry represents a single zip code record.
func All ¶
func All() []Entry
All returns every entry in the dataset. The caller must not modify the slice.
func Lookup ¶
Lookup returns all entries for a given zip code. A zip may map to multiple places (e.g. shared zips across cities). Returns nil if not found.
func LookupOne ¶
LookupOne returns the first entry for a zip code, or nil if not found. Convenience wrapper for the common single-result case.
func Nearest ¶
Nearest returns the closest zip code entry to the given coordinates using the Haversine formula. Returns nil only if the dataset is empty.
func NearestN ¶
NearestN returns the N closest entries to the given coordinates, ordered by distance ascending.
func WithinRadius ¶
WithinRadius returns all entries within radiusKM kilometers of the given coordinates, ordered by distance ascending.