iso3166

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2020 License: GPL-3.0 Imports: 5 Imported by: 0

README

iso3316

Implementing ISO3316-1 alpha-2 two letter country codes

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseColumnFormat

func ParseColumnFormat(r io.Reader) ([][3]string, error)

ParseColumnFormat parses r as a 3 column file with a whitespace character as a separator. Column 1 is the alpha-2 code, column 2 is the alpha-3 code, column 3 is the countries name.

Example: DJ DJI Djibouti SE SWE Sweden IR IRN Iran, Islamic Republic ZW ZWE Zimbabwe

Types

type AlphaThreeCountryCode

type AlphaThreeCountryCode string

AlphaThreeCountryCode - data type containing three character ISO3166 alpha-3 code

func (AlphaThreeCountryCode) String

func (cc AlphaThreeCountryCode) String() string

String - implements Stringer. Returns the three character code as a string.

type AlphaTwoCountryCode

type AlphaTwoCountryCode string

AlphaTwoCountryCode - data type containing two character ISO3166 alpha-2 code

func (AlphaTwoCountryCode) String

func (cc AlphaTwoCountryCode) String() string

String - implements Stringer. Returns the two character code as a string.

type Country

type Country struct {
	// contains filtered or unexported fields
}

Country - contains information about the country

func (Country) Name

func (c Country) Name() string

Name returns the country name

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store contains indexes allowing countries to be searched by their alpha2 or alpha3 code.

func New

func New(list [][3]string) (*Store, error)

New creates a Store initialized with the parsed country file in list.

func (*Store) GetAlphaTwoCodes

func (s *Store) GetAlphaTwoCodes() []AlphaTwoCountryCode

GetAlphaTwoCodes returns a list of all alpha-2 codes.

func (*Store) GetCountryCode

func (s *Store) GetCountryCode(cc AlphaTwoCountryCode) (*Country, bool)

GetCountryCode searches for country info using the alpha-2 code cc. The second argument indicates whether the search was successful.

Jump to

Keyboard shortcuts

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