Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // List contains all countries as a slice of Ident structs. List []Ident // ListedByName provides quick lookup by country name (uppercase). ListedByName map[string]*Ident // ListedByAlpha2 provides quick lookup by 2-letter country code (uppercase). ListedByAlpha2 map[string]*Ident // ListedByAlpha3 provides quick lookup by 3-letter country code (uppercase). ListedByAlpha3 map[string]*Ident // ListedByIsoNum provides quick lookup by ISO numeric country code. ListedByIsoNum map[uint16]*Ident // ErrNotFound is returned when a country lookup fails. ErrNotFound = errors.New("country not found") )
Functions ¶
func ExistsAlpha2 ¶
ExistsAlpha2 checks if a country with the given Alpha2 code exists (case-insensitive).
func ExistsAlpha3 ¶
ExistsAlpha3 checks if a country with the given Alpha3 code exists (case-insensitive).
func ExistsISONum ¶
ExistsISONum checks if a country with the given ISO numeric code exists.
Types ¶
type Ident ¶
type Ident struct {
// Name - is an official country name in uppercase (e.g., "CANADA").
Name string `json:"name"`
// Alpha2 - 2-letter country code (e.g., "CA").
Alpha2 string `json:"alpha2"`
// Alpha3 - 3-letter country code (e.g., "CAN").
Alpha3 string `json:"alpha3"`
// ISONum - ISO numeric country code (e.g., 124).
ISONum uint16 `json:"iso_num"`
}
Ident represents a country with its standard identifiers. All fields use official ISO 3166-1 naming and codes.
func ByAlpha2Code ¶
ByAlpha2Code finds a country by its 2-letter ISO code (case-insensitive). Returns ErrNotFound if no matching country exists.
func ByAlpha3Code ¶
ByAlpha3Code finds a country by its 3-letter ISO code (case-insensitive). Returns ErrNotFound if no matching country exists.
Click to show internal directories.
Click to hide internal directories.