Documentation
¶
Index ¶
Constants ¶
const ( LangEnglish = "en" LangChinese = "zh-CN" LangRussian = "ru" LangJapanese = "ja" LangGerman = "de" LangFrench = "fr" LangSpanish = "es" LangPortuguese = "pt-BR" LangPersian = "fa" LangKorean = "ko" DefaultLanguage = LangChinese )
Supported languages for geolocation information.
Variables ¶
var DatabaseLanguage string
var IDInfos map[string]string
IDInfos contains mapping from GeoNameID to its respective information.
var Language string
Language to be used for names.
var NameInfos map[string]map[string]map[string]string
NameInfos contains a multilevel mapping from field -> language -> name -> information.
var SupportedLanguages = []string{LangEnglish, LangChinese, LangRussian, LangJapanese, LangGerman, LangFrench, LangSpanish, LangPortuguese, LangPersian, LangKorean}
Functions ¶
func GetNameInfos ¶
GetNameInfos retrieves geolocation information based on a given field and language.
func SetDBLanguage ¶
SetDBLanguage sets the language for the database. It returns an error if the provided language is not supported.
func SetLanguage ¶
SetLanguage sets the global language for geolocation information.
Types ¶
type Info ¶
type Info struct { GeoNameID int `json:"geoname_id"` // GeoNameID is the ID of the record in the GeoNames database. Names map[string]string `json:"names"` // Names is map of locale codes to the name in that locale. Code string `json:"code"` // Code is the Code for Continent. IsoCode string `json:"iso_code"` // IsoCode is the ISO Code for the country or subdivision. IsInEuropeanUnion bool `json:"is_in_european_union"` // IsInEuropeanUnion is true if the country is a member state of the European Union. ConnectionID int `json:"-"` // ConnectionID is the GeoNameID for the Connection Type. CountryID int `json:"-"` // CountryID is the GeoNameID for the Country. SubdivisionIDs []int `json:"-"` // SubdivisionIDs is an array of GeoNameIDs for the Subdivisions(regions). }
Info represents the geolocation information.
func GetInfoByID ¶
GetInfoByID retrieves geolocation info by its GeoNameID.
func GetInfoByName ¶
GetInfoByName retrieves geolocation info by its name.
func ParseGeoInfo ¶
ParseGeoInfo parses a geolocation info from a formatted string. Format: GeoNameID, Names, Code, ISO-Code, IsInEuropeanUnion, ConnectionID, CountryID, SubdivisionIDs
func ParseInfoFromMMDB ¶
ParseInfoFromMMDB extracts geolocation info from a MMDB map.