countrycodes

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnglishName

func EnglishName(code string) (string, bool)

EnglishName returns the English country name for a code, if available.

func IsLoaded

func IsLoaded() bool

IsLoaded reports whether country data has been loaded.

func IsValid

func IsValid(code string) bool

IsValid returns true if the value is an ISO 3166-1 alpha-2 country code.

func LoadCSV

func LoadCSV(r io.Reader) error

LoadCSV populates the country code map from a CSV reader with ISO 3166 data. The CSV must have headers and at least columns "name" and "alpha-2".

func LocalizedName

func LocalizedName(code string, locale string) string

LocalizedName returns a localized name using CLDR via golang.org/x/text. Falls back to the English name or code if localization is unavailable.

func MustLoadCSV

func MustLoadCSV(r io.Reader)

MustLoadCSV loads CSV data or panics. Intended for wiring during startup.

func Normalize

func Normalize(code string) string

Normalize trims whitespace and uppercases the country code.

Types

This section is empty.

Jump to

Keyboard shortcuts

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