currencyutil

package
v0.64.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2024 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	CurrencyAFN = "AFN" // Afghanistan Afghani
	CurrencyALL = "ALL" // Albania Lek
	CurrencyANG = "ANG" // Netherlands Antilles Guilder
	CurrencyARS = "ARS" // Argentina Peso
	CurrencyAUD = "AUD" // Australia Dollar
	CurrencyAWG = "AWG" // Aruba Guilder
	CurrencyAZN = "AZN" // Azerbaijan New Manat
	CurrencyBAM = "BAM" // Bosnia and Herzegovina Convertible Marka
	CurrencyBBD = "BBD" // Barbados Dollar
	CurrencyBGN = "BGN" // Bulgaria Lev
	CurrencyBHD = "BHD" // Bahrain Dinar
	CurrencyBIF = "BIF" // Burundian Franc
	CurrencyBMD = "BMD" // Bermuda Dollar
	CurrencyBND = "BND" // Brunei Darussalam Dollar
	CurrencyBOB = "BOB" // Bolivia Bolíviano
	CurrencyBRL = "BRL" // Brazil Real
	CurrencyBSD = "BSD" // Bahamas Dollar
	CurrencyBTC = "BTC" // Crypto Bitcoin
	CurrencyBWP = "BWP" // Botswana Pula
	CurrencyBYN = "BYN" // Belarus Ruble
	CurrencyBZD = "BZD" // Belize Dollar
	CurrencyCAD = "CAD" // Canada Dollar
	CurrencyCHF = "CHF" // Switzerland Franc
	CurrencyCLP = "CLP" // Chile Peso
	CurrencyCNY = "CNY" // China Yuan Renminbi
	CurrencyCRC = "CRC" // Costa Rica Colon
	CurrencyCUP = "CUP" // Cuba Peso
	CurrencyDJF = "DJF" // Djibouti Franc
	CurrencyDKK = "DKK" // Danish Krone
	CurrencyEGP = "EGP" // Egypt Pound
	CurrencyETH = "ETH" // Crypto Ether
	CurrencyEUR = "EUR" // Eurozone Euro
	CurrencyFKP = "FKP" // Falkland Islands Pound
	CurrencyGBP = "GBP" // United Kingdom Pound
	CurrencyGNF = "GNF" // Guinean Franc
	CurrencyHKD = "HKD" // Hong Kong Dollar
	CurrencyIDR = "IDR" // Indonesian Rupiah
	CurrencyILS = "ILS" // Israel Shekel
	CurrencyINR = "INR" // Indian Rupee
	CurrencyIRR = "IRR" // Iran Rial
	CurrencyJOD = "JOD" // Jordan Dinar
	CurrencyJPY = "JPY" // Japan Yen
	CurrencyKGS = "KGS" // Kyrgyzstan Som
	CurrencyKHR = "KHR" // Cambodia Riel
	CurrencyKMF = "KMF" // Comorian Franc
	CurrencyKPW = "KPW" // North Korea Won
	CurrencyKRW = "KRW" // South Korea Won
	CurrencyKWD = "KWD" // Kuwait Dinar
	CurrencyLKR = "LKR" // Sri Lanka Rupee
	CurrencyLTC = "LTC" // Crypto Litecoin
	CurrencyMGA = "MGA" // Malagasy Ariary
	CurrencyMNT = "MNT" // Mongolia Tughrik
	CurrencyMUR = "MUR" // Mauritius Rupee
	CurrencyMXN = "MXN" // Mexican Peso
	CurrencyMYR = "MYR" // Malaysia Ringgit
	CurrencyNGN = "NGN" // Nigeria Naira
	CurrencyNOK = "NOK" // Norway Krone
	CurrencyNPR = "NPR" // Nepal Rupee
	CurrencyNZD = "NZD" // New Zealand Dollar
	CurrencyOMR = "OMR" // Oman Rial
	CurrencyPHP = "PHP" // Philippines Peso
	CurrencyPKR = "PKR" // Pakistan Rupee
	CurrencyPLN = "PLN" // Poland Zloty
	CurrencyPYG = "PYG" // Paraguayan Guarani
	CurrencyQAR = "QAR" // Qatar Riyal
	CurrencyRON = "RON" // Romania New Leu
	CurrencyRSD = "RSD" // Serbia Dinar
	CurrencyRUB = "RUB" // Russia Ruble
	CurrencyRWF = "RWF" // Rwandan Franc
	CurrencySAR = "SAR" // Saudi Arabia Riyal
	CurrencySCR = "SCR" // Seychelles Rupee
	CurrencySEK = "SEK" // Sweden Krona
	CurrencySGD = "SGD" // Singapore Dollar
	CurrencySYP = "SYP" // Syria Pound
	CurrencyTHB = "THB" // Thailand Baht
	CurrencyTND = "TND" // Tunisia Dinar
	CurrencyTRY = "TRY" // Turkey Lira
	CurrencyTWD = "TWD" // Taiwan Dollar
	CurrencyUAH = "UAH" // Ukraine Hryvnia
	CurrencyUGX = "UGX" // Uganda Shilling
	CurrencyUSD = "USD" // United States Dollar
	CurrencyUZS = "UZS" // Uzbekistan Som
	CurrencyVND = "VND" // Viet Nam Dong
	CurrencyVUV = "VUV" // Vanuatu Vatu
	CurrencyXAF = "XAF" // Central African CFA Franc
	CurrencyXAG = "XAG" // Metal Silver
	CurrencyXAU = "XAU" // Metal Gold
	CurrencyXOF = "XOF" // West African CFA Franc
	CurrencyXPD = "XPD" // Metal Palladium
	CurrencyXPF = "XPF" // CFP Franc
	CurrencyXPT = "XPT" // Metal Platinum
	CurrencyXTS = "XTS" // Testing Testing
	CurrencyXXX = "XXX" // Undefined Undefined
	CurrencyYER = "YER" // Yemen Rial
	CurrencyZAR = "ZAR" // South Africa Rand
)
View Source
const (
	USDSymbol          = "$"
	UnitsBillionsDesc  = "billions"
	UnitsBillionsInt   = 1000000000
	UnitsMillionsDesc  = "millions"
	UnitsMillionsInt   = 1000000
	UnitsThousandsDesc = "thousands"
	UnitsThousandsInt  = 1000
)

Variables

View Source
var (
	ErrUnknownCurrencyPrefix = errors.New("unknown currency prefix")
	ErrUnknownCurrencySuffix = errors.New("unknown currency suffix")
)
View Source
var ErrNoCurrencyCode = errors.New("currency code not set")
View Source
var ErrSymbolNotFound = errors.New("symbol not found")
View Source
var SymbolMap = map[string]string{
	"AFN": "؋",
	"ARS": "$",
	"AWG": "ƒ",
	"BRL": "R$",
	"CAD": "$",
	"CLP": "$",
	"CNY": "¥",
	"CRC": "₡",
	"CUP": "₱",
	"EGP": "£",
	"EUR": "€",
	"FKP": "£",
	"GBP": "£",
	"ILS": "₪",
	"IRR": "﷼",
	"JPY": "¥",
	"KHR": "៛",
	"KLR": "₨",
	"KPW": "₩",
	"KRW": "₩",
	"MNT": "₮",
	"NGN": "₦",
	"NOK": "kr",
	"PHP": "₱",
	"PLN": "zł",
	"RUB": "₽",
	"SAR": "﷼",
	"THB": "฿",
	"UAH": "₴",
	"USD": "$",
	"UZS": "лв",
	"VND": "₫",
	"YER": "﷼"}

Functions

func CurrencyCanonical

func CurrencyCanonical(value string) string

func CurrencyCodeKnown

func CurrencyCodeKnown(value string) bool

func CurrencyCodes0D

func CurrencyCodes0D() []string

CurrencyCodes0D returns zero decimal currencies. Listed at: https://stripe.com/docs/currencies

func CurrencyCodes3D

func CurrencyCodes3D() []string

CurrencyCodes3D returns three decimal currencies. Listed at: https://stripe.com/docs/currencies

func CurrencyCodesAll

func CurrencyCodesAll() []string

func MustSymbol

func MustSymbol(iso4217 string) string

func MustSymbolOrDefault

func MustSymbolOrDefault(iso4217, defSymbol string) string

func ParseCurrency

func ParseCurrency(opts *ParseCurrencyOpts, s string) (string, float64, error)

func ParseCurrencyUnit

func ParseCurrencyUnit(abbr, symbol string) (string, error)

func Symbol

func Symbol(iso4217 string) (string, error)

func SymbolPrefix

func SymbolPrefix(iso4217 string) string

Types

type Currencies

type Currencies []Currency

func (Currencies) Codes

func (c Currencies) Codes() []string

type Currency

type Currency struct {
	Code    string
	Symbol  string
	Country string
	Name    string
}

func (*Currency) TrimSpace

func (c *Currency) TrimSpace()

type CurrencySet

type CurrencySet struct {
	Map map[string]Currency
}

func NewCurrencySet

func NewCurrencySet(c ...Currency) (CurrencySet, error)

func (*CurrencySet) Add

func (set *CurrencySet) Add(c ...Currency) error

func (CurrencySet) Codes

func (set CurrencySet) Codes() []string

type ExchangeRateSimple

type ExchangeRateSimple struct {
	BaseCurrency  string
	CurrencyRates map[string]float64
}

func ExampleExchangeRates

func ExampleExchangeRates() ExchangeRateSimple

func (*ExchangeRateSimple) ConvertToBase

func (xr *ExchangeRateSimple) ConvertToBase(in float64, cur string) (float64, error)

type ParseCurrencyOpts

type ParseCurrencyOpts struct {
	Comma         string
	Decimal       string
	BillionsAbbr  []string
	MillionsAbbr  []string
	ThousandsAbbr []string
}

func NewParseCurrencyOpts

func NewParseCurrencyOpts() ParseCurrencyOpts

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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