geo

package
v0.0.0-...-277150b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UndefinedCountryCodeISO2 = gogeo.UndefinedCountryCodeISO2
	UndefinedCountryCodeISO3 = gogeo.UndefinedCountryCodeISO3
	UndefinedRegionISO3166   = gogeo.UndefinedRegionISO3166
)

Variables

View Source
var (
	UndefinedCountryCode2        = gogeo.UndefinedCountryCode2
	UndefinedRegionCode          = gogeo.UndefinedRegionCode
	ErrCode2InvalidScanType      = gogeo.ErrCode2InvalidScanType
	ErrCode2InvalidValueSize     = gogeo.ErrCode2InvalidValueSize
	ErrRegionCodeInvalidScanType = gogeo.ErrRegionCodeInvalidScanType

	// Continents is the static continent catalog (IDs 1..7).
	Continents = gogeo.Continents
	// Countries is the static country catalog. Index equals Country.ID.
	Countries = gogeo.Countries
	// Regions is the static ISO 3166-2 catalog. Index equals Region.ID.
	Regions = gogeo.Regions
)

Functions

func CountryCodes2IDs

func CountryCodes2IDs(codes []string) gosql.NullableOrderedNumberArray[uint64]

CountryCodes2IDs convert country codes to country IDs. Continent codes EU, AS, AF, OC, SA, NA, AN expand to all countries on that continent.

func RegionCodes2IDs

func RegionCodes2IDs(codes []string) gosql.NullableOrderedNumberArray[uint64]

RegionCodes2IDs convert ISO 3166-2 region codes to region IDs. Unrecognised codes resolve to ID 0 (undefined).

Types

type Continent

type Continent = gogeo.Continent

Type aliases keep gogeo methods and stay assignable to udetect.Geo fields.

func ContinentByCode2

func ContinentByCode2(code string) *Continent

ContinentByCode2 returns a continent by 2-letter code, or nil.

type Coordinates

type Coordinates = gogeo.Coordinates

Type aliases keep gogeo methods and stay assignable to udetect.Geo fields.

type Country

type Country = gogeo.Country

Type aliases keep gogeo methods and stay assignable to udetect.Geo fields.

func CountriesByContinent

func CountriesByContinent(code string) []Country

CountriesByContinent returns countries whose continent code matches. Unknown or empty continent codes yield nil.

func CountryByCode

func CountryByCode(code string) *Country

CountryByCode returns the country for an ISO-2 or ISO-3 code.

func CountryByCode2

func CountryByCode2(code string) *Country

CountryByCode2 returns the country for an ISO-2 code. Unknown codes resolve to the undefined country (never nil).

func CountryByCode2Bytes

func CountryByCode2Bytes(code CountryCode2) *Country

CountryByCode2Bytes is the allocation-free ISO-2 lookup. Unknown codes resolve to the undefined country (never nil).

func CountryByCode3

func CountryByCode3(code string) *Country

CountryByCode3 returns the country for an ISO-3 code. Empty and unknown codes resolve to the undefined country (never nil).

func CountryByID

func CountryByID(id uint8) *Country

CountryByID returns the country with the given ID, or the undefined country.

type CountryCode2

type CountryCode2 = gogeo.CountryCode2

Type aliases keep gogeo methods and stay assignable to udetect.Geo fields.

func CountryCode2ByString

func CountryCode2ByString(code string) CountryCode2

CountryCode2ByString returns a Code2 from an ISO-2 or ISO-3 string.

type Region

type Region = gogeo.Region

Type aliases keep gogeo methods and stay assignable to udetect.Geo fields.

func RegionByCode

func RegionByCode(code string) *Region

RegionByCode returns the region for an ISO 3166-2 code (for example "US-CA"). "GB-*" and "UK-*" resolve to the same United Kingdom subdivisions. Unknown codes resolve to the undefined region (never nil).

func RegionByID

func RegionByID(id uint16) *Region

RegionByID returns the region with the given ID, or the undefined region.

func RegionByLatLng

func RegionByLatLng(lat, lng float32) *Region

RegionByLatLng returns the nearest region with coordinates, or undefined.

type RegionCode

type RegionCode = gogeo.RegionCode

Type aliases keep gogeo methods and stay assignable to udetect.Geo fields.

func RegionCodeByPartial

func RegionCodeByPartial(code string, country CountryCode2) RegionCode

RegionCodeByPartial accepts a full ISO 3166-2 code ("SK-BA") or a subdivision suffix ("BA") when the parent country is known. Empty and unknown values return UndefinedRegionCode.

func RegionCodeByString

func RegionCodeByString(code string) RegionCode

RegionCodeByString parses an ISO 3166-2 code. Unknown values become undefined.

type TimeZone

type TimeZone = gogeo.TimeZone

Type aliases keep gogeo methods and stay assignable to udetect.Geo fields.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL