iso3166

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidAlpha  = errors.New("iso3166: country alpha codes must be 2 or 3 uppercase characters")
	ErrInvalidAlpha2 = errors.New("iso3166: country alpha-2 codes must be 2 uppercase characters")
	ErrInvalidAlpha3 = errors.New("iso3166: country alpha-2 codes must be 3 uppercase characters")
)

Validation Errors

Functions

func NotACountry added in v1.4.0

func NotACountry(alpha string) error

func Validate added in v1.4.0

func Validate(alpha string) error

func ValidateAlpha2 added in v1.4.0

func ValidateAlpha2(alpha string) error

func ValidateAlpha3 added in v1.4.0

func ValidateAlpha3(alpha string) error

Types

type AlphaCode

type AlphaCode struct {
	Country string
	Alpha2  string
	Alpha3  string
	Numeric string
}

AlphaCode maps country to alpha-2 and alpha-3 ISO 3166-1 codes and their numeric code.

func Find

func Find(s string) (_ AlphaCode, err error)

Find a country alpha code by the country name, 2 or 3 digit alpha code, or numeric code. An error is returned if the country can't be found.

func List

func List() (codes []*AlphaCode)

List all country codes that are stored in the module

Jump to

Keyboard shortcuts

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