country

package
v0.0.0-...-f3f6071 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AltCodes = map[string]Code{

	"A":   AT,
	"DEU": DE,

	"AUT": AT,
	"B":   BR,
	"D":   DE,
	"E":   ES,
	"F":   FR,
	"G":   GB,
	"I":   IT,
	"J":   JP,
	"S":   SE,
	"SUI": CH,
}

AltCodes

Functions

This section is empty.

Types

type Code

type Code string

Code for a country according ISO 3166-1 alpha 2. Code implements the database/sql.Scanner and database/sql/driver.Valuer interfaces, and will treat an empty Code string as SQL NULL. See NullableCode

const (
	AF Code = "AF"
	AX Code = "AX"
	AL Code = "AL"
	DZ Code = "DZ"
	AS Code = "AS"
	AO Code = "AO"
	AI Code = "AI"
	AQ Code = "AQ"
	AG Code = "AG"
	AR Code = "AR"
	AM Code = "AM"
	AW Code = "AW"
	AU Code = "AU"
	AT Code = "AT"
	AZ Code = "AZ"
	BS Code = "BS"
	BH Code = "BH"
	BD Code = "BD"
	BB Code = "BB"
	BY Code = "BY"
	BE Code = "BE"
	BZ Code = "BZ"
	BJ Code = "BJ"
	BM Code = "BM"
	BT Code = "BT"
	BO Code = "BO"
	BQ Code = "BQ"
	BA Code = "BA"
	BW Code = "BW"
	BV Code = "BV"
	BR Code = "BR"
	IO Code = "IO"
	BN Code = "BN"
	BG Code = "BG"
	BF Code = "BF"
	BI Code = "BI"
	KH Code = "KH"
	CM Code = "CM"
	CA Code = "CA"
	CV Code = "CV"
	KY Code = "KY"
	CF Code = "CF"
	TD Code = "TD"
	CL Code = "CL"
	CN Code = "CN"
	CX Code = "CX"
	CC Code = "CC"
	CO Code = "CO"
	KM Code = "KM"
	CG Code = "CG"
	CD Code = "CD"
	CK Code = "CK"
	CR Code = "CR"
	CI Code = "CI"
	HR Code = "HR"
	CU Code = "CU"
	CW Code = "CW"
	CY Code = "CY"
	CZ Code = "CZ"
	DK Code = "DK"
	DJ Code = "DJ"
	DM Code = "DM"
	DO Code = "DO"
	EC Code = "EC"
	EG Code = "EG"
	SV Code = "SV"
	GQ Code = "GQ"
	ER Code = "ER"
	EE Code = "EE"
	ET Code = "ET"
	FK Code = "FK"
	FO Code = "FO"
	FJ Code = "FJ"
	FI Code = "FI"
	FR Code = "FR"
	GF Code = "GF"
	PF Code = "PF"
	TF Code = "TF"
	GA Code = "GA"
	GM Code = "GM"
	GE Code = "GE"
	DE Code = "DE"
	GH Code = "GH"
	GI Code = "GI"
	GR Code = "GR"
	EL Code = "EL"
	GL Code = "GL"
	GD Code = "GD"
	GP Code = "GP"
	GU Code = "GU"
	GT Code = "GT"
	GG Code = "GG"
	GN Code = "GN"
	GW Code = "GW"
	GY Code = "GY"
	HT Code = "HT"
	HM Code = "HM"
	VA Code = "VA"
	HN Code = "HN"
	HK Code = "HK"
	HU Code = "HU"
	IS Code = "IS"
	IN Code = "IN"
	ID Code = "ID"
	IR Code = "IR"
	IQ Code = "IQ"
	IE Code = "IE"
	IM Code = "IM"
	IL Code = "IL"
	IT Code = "IT"
	JM Code = "JM"
	JP Code = "JP"
	JE Code = "JE"
	JO Code = "JO"
	KZ Code = "KZ"
	KE Code = "KE"
	KI Code = "KI"
	KP Code = "KP"
	KR Code = "KR"
	KW Code = "KW"
	KG Code = "KG"
	LA Code = "LA"
	LV Code = "LV"
	LB Code = "LB"
	LS Code = "LS"
	LR Code = "LR"
	LY Code = "LY"
	LI Code = "LI"
	LT Code = "LT"
	LU Code = "LU"
	MO Code = "MO"
	MK Code = "MK"
	MG Code = "MG"
	MW Code = "MW"
	MY Code = "MY"
	MV Code = "MV"
	ML Code = "ML"
	MT Code = "MT"
	MH Code = "MH"
	MQ Code = "MQ"
	MR Code = "MR"
	MU Code = "MU"
	YT Code = "YT"
	MX Code = "MX"
	FM Code = "FM"
	MD Code = "MD"
	MC Code = "MC"
	MN Code = "MN"
	ME Code = "ME"
	MS Code = "MS"
	MA Code = "MA"
	MZ Code = "MZ"
	MM Code = "MM"
	NA Code = "NA"
	NR Code = "NR"
	NP Code = "NP"
	NL Code = "NL"
	NC Code = "NC"
	NZ Code = "NZ"
	NI Code = "NI"
	NE Code = "NE"
	NG Code = "NG"
	NU Code = "NU"
	NF Code = "NF"
	MP Code = "MP"
	NO Code = "NO"
	OM Code = "OM"
	PK Code = "PK"
	PW Code = "PW"
	PS Code = "PS"
	PA Code = "PA"
	PG Code = "PG"
	PY Code = "PY"
	PE Code = "PE"
	PH Code = "PH"
	PN Code = "PN"
	PL Code = "PL"
	PT Code = "PT"
	PR Code = "PR"
	QA Code = "QA"
	RE Code = "RE"
	RO Code = "RO"
	RU Code = "RU"
	RW Code = "RW"
	BL Code = "BL"
	SH Code = "SH"
	KN Code = "KN"
	LC Code = "LC"
	MF Code = "MF"
	PM Code = "PM"
	VC Code = "VC"
	WS Code = "WS"
	SM Code = "SM"
	ST Code = "ST"
	SA Code = "SA"
	SN Code = "SN"
	RS Code = "RS"
	SC Code = "SC"
	SL Code = "SL"
	SG Code = "SG"
	SX Code = "SX"
	SK Code = "SK"
	SI Code = "SI"
	SB Code = "SB"
	SO Code = "SO"
	ZA Code = "ZA"
	GS Code = "GS"
	SS Code = "SS"
	ES Code = "ES"
	LK Code = "LK"
	SD Code = "SD"
	SR Code = "SR"
	SJ Code = "SJ"
	SZ Code = "SZ"
	SE Code = "SE"
	CH Code = "CH"
	SY Code = "SY"
	TW Code = "TW"
	TJ Code = "TJ"
	TZ Code = "TZ"
	TH Code = "TH"
	TL Code = "TL"
	TG Code = "TG"
	TK Code = "TK"
	TO Code = "TO"
	TT Code = "TT"
	TN Code = "TN"
	TR Code = "TR"
	TM Code = "TM"
	TC Code = "TC"
	TV Code = "TV"
	UG Code = "UG"
	UA Code = "UA"
	AE Code = "AE"
	GB Code = "GB"
	US Code = "US"
	UM Code = "UM"
	UY Code = "UY"
	UZ Code = "UZ"
	VU Code = "VU"
	VE Code = "VE"
	VN Code = "VN"
	VG Code = "VG"
	VI Code = "VI"
	WF Code = "WF"
	EH Code = "EH"
	YE Code = "YE"
	ZM Code = "ZM"
	ZW Code = "ZW"
	XK Code = "XK"
)
const Invalid Code = ""

func (Code) EnglishName

func (c Code) EnglishName() string

func (Code) IsEU

func (c Code) IsEU() bool

IsEU indicates if a country is member of the European Union

func (Code) MarshalJSON

func (c Code) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler

func (Code) Normalized

func (c Code) Normalized() (Code, error)

func (Code) NormalizedWithAltCodes

func (c Code) NormalizedWithAltCodes() (Code, error)

NormalizedWithAltCodes uses AltCodes to map to ISO 3166-1 alpha 2 codes or return the result of Normalized() if no mapping exists.

func (Code) Nullable

func (c Code) Nullable() NullableCode

Nullable returns the Code as NullableCode. Country code Invalid is returned as Null.

func (*Code) Scan

func (c *Code) Scan(value any) error

Scan implements the database/sql.Scanner interface.

func (*Code) ScanString

func (c *Code) ScanString(source string, validate bool) error

ScanString tries to parse and assign the passed source string as value of the implementing type.

If validate is true, the source string is checked for validity before it is assigned to the type.

If validate is false and the source string can still be assigned in some non-normalized way it will be assigned without returning an error.

func (Code) String

func (c Code) String() string

String returns the normalized code if possible, else it will be returned unchanged as string. String implements the fmt.Stringer interface.

func (Code) Valid

func (c Code) Valid() bool

func (Code) Validate

func (c Code) Validate() error

func (Code) Value

func (c Code) Value() (driver.Value, error)

Value implements the driver database/sql/driver.Valuer interface.

type NullableCode

type NullableCode string

NullableCode for a country according ISO 3166-1 alpha 2. NullableCode implements the database/sql.Scanner and database/sql/driver.Valuer interfaces, and will treat an empty NullableCode string as SQL NULL. Null.Valid() or NullableCode("").Valid() will return true.

const Null NullableCode = ""

func (NullableCode) EnglishName

func (n NullableCode) EnglishName() string

func (NullableCode) Get

func (n NullableCode) Get() Code

Get returns the non nullable ID value or panics if the NullableCode is null. Note: check with IsNull before using Get!

func (NullableCode) GetOr

func (n NullableCode) GetOr(defaultCode Code) Code

GetOr returns the non nullable Code value or the passed defaultCode if the NullableCode is null.

func (NullableCode) IsEU

func (n NullableCode) IsEU() bool

IsEU indicates if a country is member of the European Union

func (NullableCode) IsNotNull

func (n NullableCode) IsNotNull() bool

IsNotNull returns true if the NullableCode is not null.

func (NullableCode) IsNull

func (n NullableCode) IsNull() bool

IsNull returns true if the NullableID is null. IsNull implements the nullable.Nullable interface.

func (NullableCode) MarshalJSON

func (n NullableCode) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler by returning the JSON null value for an empty (null) string.

func (NullableCode) Normalized

func (n NullableCode) Normalized() (NullableCode, error)

func (NullableCode) NormalizedOrNull

func (n NullableCode) NormalizedOrNull() NullableCode

func (NullableCode) NormalizedWithAltCodes

func (n NullableCode) NormalizedWithAltCodes() (NullableCode, error)

NormalizedWithAltCodes uses AltCodes to map to ISO 3166-1 alpha 2 codes or return the result of Normalized() if no mapping exists.

func (*NullableCode) Scan

func (n *NullableCode) Scan(value any) error

Scan implements the database/sql.Scanner interface.

func (*NullableCode) ScanString

func (n *NullableCode) ScanString(source string, validate bool) error

ScanString tries to parse and assign the passed source string as value of the implementing type.

If validate is true, the source string is checked for validity before it is assigned to the type.

If validate is false and the source string can still be assigned in some non-normalized way it will be assigned without returning an error.

func (*NullableCode) Set

func (n *NullableCode) Set(code Code)

Set sets an ID for this NullableCode

func (*NullableCode) SetNull

func (n *NullableCode) SetNull()

SetNull sets the NullableCode to null

func (NullableCode) String

func (n NullableCode) String() string

String returns the normalized code if possible, else it will be returned unchanged as string. String implements the fmt.Stringer interface.

func (NullableCode) StringOr

func (n NullableCode) StringOr(defaultString string) string

StringOr returns the NullableCode as string or the passed defaultString if the NullableCode is null.

func (NullableCode) Valid

func (n NullableCode) Valid() bool

func (NullableCode) ValidAndNotNull

func (n NullableCode) ValidAndNotNull() bool

func (NullableCode) Validate

func (n NullableCode) Validate() error

func (NullableCode) Value

func (n NullableCode) Value() (driver.Value, error)

Value implements the driver database/sql/driver.Valuer interface.

Jump to

Keyboard shortcuts

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