- Home
- Packages
- Go
- infobits-intl
- Documentation
- Currencies
Currencies
Currencies
The package includes 179+ currencies with ISO 4217 codes.
Currency Properties
Each currency has the following fields:
| Field | Description |
|---|---|
code | ISO 4217 currency code (e.g. "USD") |
nativeName | Singular name (e.g. "US Dollar") |
nativeNamePlural | Plural name (e.g. "US Dollars") |
symbol | Currency symbol (e.g. "$") |
Lookup by Code
currency, ok := intl.CurrencyByCode("USD")
if ok {
fmt.Println(currency.NativeName) // US Dollar
fmt.Println(currency.NativeNamePlural) // US Dollars
fmt.Println(currency.Symbol) // $
}List All Currencies
allCurrencies := intl.AllCurrencies()
fmt.Println(len(allCurrencies)) // 179Currency for a Country
Each country has a linked currency.
country, ok := intl.CountryByAlpha2("JP")
if ok {
currency, cOk := intl.CurrencyByCode(country.Currency)
if cOk {
fmt.Println(currency.NativeName) // Japanese Yen
fmt.Println(currency.Symbol) // ??
}
}Type-Safe Currency Codes
code := intl.CurrencyEUR
currency := code.Currency()
fmt.Println(currency.NativeName) // Euro
fmt.Println(currency.Symbol) // ???