Documentation ¶
Index ¶
- Variables
- type Currency
- type Money
- func (m Money) Add(x Money) (Money, error)
- func (m Money) Compare(x Money) (int, error)
- func (m Money) Divide(x decimal.Decimal) (Money, error)
- func (m Money) Equal(x Money) (bool, error)
- func (m Money) FormattedString() string
- func (m Money) Multiply(x decimal.Decimal) Money
- func (m Money) String() string
- func (m Money) Subtract(x Money) (Money, error)
Constants ¶
This section is empty.
Variables ¶
var AED = Currency{"AED", 2}
AED United Arab Emirates dirham
var AFN = Currency{"AFN", 2}
AFN Afghan afghani
var ALL = Currency{"ALL", 2}
ALL Albanian lek
var AMD = Currency{"AMD", 2}
AMD Armenian dram
var ANG = Currency{"ANG", 2}
ANG Netherlands Antillean guilder
var AOA = Currency{"AOA", 2}
AOA Angolan kwanza
var ARS = Currency{"ARS", 2}
ARS Argentine peso
var AUD = Currency{"AUD", 2}
AUD Australian dollar
var AWG = Currency{"AWG", 2}
AWG Aruban florin
var AZN = Currency{"AZN", 2}
AZN Azerbaijani manat
var BAM = Currency{"BAM", 2}
BAM Bosnia and Herzegovina convertible mark
var BBD = Currency{"BBD", 2}
BBD Barbados dollar
var BDT = Currency{"BDT", 2}
BDT Bangladeshi taka
var BGN = Currency{"BGN", 2}
BGN Bulgarian lev
var BHD = Currency{"BHD", 3}
BHD Bahraini dinar
var BIF = Currency{"BIF", 0}
BIF Burundian franc
var BMD = Currency{"BMD", 2}
BMD Bermudian dollar
var BND = Currency{"BND", 2}
BND Brunei dollar
var BOB = Currency{"BOB", 2}
BOB Boliviano
var BOV = Currency{"BOV", 2}
BOV Bolivian Mvdol (funds code)
var BRL = Currency{"BRL", 2}
BRL Brazilian real
var BSD = Currency{"BSD", 2}
BSD Bahamian dollar
var BTN = Currency{"BTN", 2}
BTN Bhutanese ngultrum
var BWP = Currency{"BWP", 2}
BWP Botswana pula
var BYN = Currency{"BYN", 2}
BYN Belarusian ruble
var BZD = Currency{"BZD", 2}
BZD Belize dollar
var CAD = Currency{"CAD", 2}
CAD Canadian dollar
var CDF = Currency{"CDF", 2}
CDF Congolese franc
var CHE = Currency{"CHE", 2}
CHE WIR Euro (complementary currency)
var CHF = Currency{"CHF", 2}
CHF Swiss franc
var CHW = Currency{"CHW", 2}
CHW WIR Franc (complementary currency)
var CLF = Currency{"CLF", 4}
CLF Unidad de Fomento (funds code)
var CLP = Currency{"CLP", 0}
CLP Chilean peso
var CNY = Currency{"CNY", 2}
CNY Renminbi (Chinese) yuan
var COP = Currency{"COP", 2}
COP Colombian peso
var COU = Currency{"COU", 2}
COU Unidad de Valor Real (UVR) (funds code)
var CRC = Currency{"CRC", 2}
CRC Costa Rican colon
var CUC = Currency{"CUC", 2}
CUC Cuban convertible peso
var CUP = Currency{"CUP", 2}
CUP Cuban peso
var CVE = Currency{"CVE", 2}
CVE Cape Verdean escudo
var CZK = Currency{"CZK", 2}
CZK Czech koruna
var DJF = Currency{"DJF", 0}
DJF Djiboutian franc
var DKK = Currency{"DKK", 2}
DKK Danish krone
var DOP = Currency{"DOP", 2}
DOP Dominican peso
var DZD = Currency{"DZD", 2}
DZD Algerian dinar
var EGP = Currency{"EGP", 2}
EGP Egyptian pound
var ERN = Currency{"ERN", 2}
ERN Eritrean nakfa
var ETB = Currency{"ETB", 2}
ETB Ethiopian birr
var EUR = Currency{"EUR", 2}
EUR Euro
var FJD = Currency{"FJD", 2}
FJD Fiji dollar
var FKP = Currency{"FKP", 2}
FKP Falkland Islands pound
var GBP = Currency{"GBP", 2}
GBP Pound sterling
var GEL = Currency{"GEL", 2}
GEL Georgian lari
var GHS = Currency{"GHS", 2}
GHS Ghanaian cedi
var GIP = Currency{"GIP", 2}
GIP Gibraltar pound
var GMD = Currency{"GMD", 2}
GMD Gambian dalasi
var GNF = Currency{"GNF", 0}
GNF Guinean franc
var GTQ = Currency{"GTQ", 2}
GTQ Guatemalan quetzal
var GYD = Currency{"GYD", 2}
GYD Guyanese dollar
var HKD = Currency{"HKD", 2}
HKD Hong Kong dollar
var HNL = Currency{"HNL", 2}
HNL Honduran lempira
var HRK = Currency{"HRK", 2}
HRK Croatian kuna
var HTG = Currency{"HTG", 2}
HTG Haitian gourde
var HUF = Currency{"HUF", 2}
HUF Hungarian forint
var IDR = Currency{"IDR", 2}
IDR Indonesian rupiah
var ILS = Currency{"ILS", 2}
ILS Israeli new shekel
var INR = Currency{"INR", 2}
INR Indian rupee
var IQD = Currency{"IQD", 3}
IQD Iraqi dinar
var IRR = Currency{"IRR", 2}
IRR Iranian rial
var ISK = Currency{"ISK", 0}
ISK Icelandic króna
var JMD = Currency{"JMD", 2}
JMD Jamaican dollar
var JOD = Currency{"JOD", 3}
JOD Jordanian dinar
var JPY = Currency{"JPY", 0}
JPY Japanese yen
var KES = Currency{"KES", 2}
KES Kenyan shilling
var KGS = Currency{"KGS", 2}
KGS Kyrgyzstani som
var KHR = Currency{"KHR", 2}
KHR Cambodian riel
var KMF = Currency{"KMF", 0}
KMF Comoro franc
var KPW = Currency{"KPW", 2}
KPW North Korean won
var KRW = Currency{"KRW", 0}
KRW South Korean won
var KWD = Currency{"KWD", 3}
KWD Kuwaiti dinar
var KYD = Currency{"KYD", 2}
KYD Cayman Islands dollar
var KZT = Currency{"KZT", 2}
KZT Kazakhstani tenge
var LAK = Currency{"LAK", 2}
LAK Lao kip
var LBP = Currency{"LBP", 2}
LBP Lebanese pound
var LKR = Currency{"LKR", 2}
LKR Sri Lankan rupee
var LRD = Currency{"LRD", 2}
LRD Liberian dollar
var LSL = Currency{"LSL", 2}
LSL Lesotho loti
var LYD = Currency{"LYD", 3}
LYD Libyan dinar
var MAD = Currency{"MAD", 2}
MAD Moroccan dirham
var MDL = Currency{"MDL", 2}
MDL Moldovan leu
var MGA = Currency{"MGA", 2}
MGA 11] Malagasy ariary
var MKD = Currency{"MKD", 2}
MKD Macedonian denar
var MMK = Currency{"MMK", 2}
MMK Myanmar kyat
var MNT = Currency{"MNT", 2}
MNT Mongolian tögrög
var MOP = Currency{"MOP", 2}
MOP Macanese pataca
var MRU = Currency{"MRU", 2}
MRU Mauritanian ouguiya
var MUR = Currency{"MUR", 2}
MUR Mauritian rupee
var MVR = Currency{"MVR", 2}
MVR Maldivian rufiyaa
var MWK = Currency{"MWK", 2}
MWK Malawian kwacha
var MXN = Currency{"MXN", 2}
MXN Mexican peso
var MXV = Currency{"MXV", 2}
MXV Mexican Unidad de Inversion (UDI) (funds code)
var MYR = Currency{"MYR", 2}
MYR Malaysian ringgit
var MZN = Currency{"MZN", 2}
MZN Mozambican metical
var NAD = Currency{"NAD", 2}
NAD Namibian dollar
var NGN = Currency{"NGN", 2}
NGN Nigerian naira
var NIO = Currency{"NIO", 2}
NIO Nicaraguan córdoba
var NOK = Currency{"NOK", 2}
NOK Norwegian krone
var NPR = Currency{"NPR", 2}
NPR Nepalese rupee
var NZD = Currency{"NZD", 2}
NZD New Zealand dollar
var OMR = Currency{"OMR", 3}
OMR Omani rial
var PAB = Currency{"PAB", 2}
PAB Panamanian balboa
var PEN = Currency{"PEN", 2}
PEN Peruvian sol
var PGK = Currency{"PGK", 2}
PGK Papua New Guinean kina
var PHP = Currency{"PHP", 2}
PHP Philippine peso
var PKR = Currency{"PKR", 2}
PKR Pakistani rupee
var PLN = Currency{"PLN", 2}
PLN Polish złoty
var PYG = Currency{"PYG", 0}
PYG Paraguayan guaraní
var QAR = Currency{"QAR", 2}
QAR Qatari riyal
var RON = Currency{"RON", 2}
RON Romanian leu
var RSD = Currency{"RSD", 2}
RSD Serbian dinar
var RUB = Currency{"RUB", 2}
RUB Russian ruble
var RWF = Currency{"RWF", 0}
RWF Rwandan franc
var SAR = Currency{"SAR", 2}
SAR Saudi riyal
var SBD = Currency{"SBD", 2}
SBD Solomon Islands dollar
var SCR = Currency{"SCR", 2}
SCR Seychelles rupee
var SDG = Currency{"SDG", 2}
SDG Sudanese pound
var SEK = Currency{"SEK", 2}
SEK Swedish krona/kronor
var SGD = Currency{"SGD", 2}
SGD Singapore dollar
var SHP = Currency{"SHP", 2}
SHP Saint Helena pound
var SLL = Currency{"SLL", 2}
SLL Sierra Leonean leone
var SOS = Currency{"SOS", 2}
SOS Somali shilling
var SRD = Currency{"SRD", 2}
SRD Surinamese dollar
var SSP = Currency{"SSP", 2}
SSP South Sudanese pound
var STN = Currency{"STN", 2}
STN São Tomé and Príncipe dobra
var SVC = Currency{"SVC", 2}
SVC Salvadoran colón
var SYP = Currency{"SYP", 2}
SYP Syrian pound
var SZL = Currency{"SZL", 2}
SZL Swazi lilangeni
var THB = Currency{"THB", 2}
THB Thai baht
var TJS = Currency{"TJS", 2}
TJS Tajikistani somoni
var TMT = Currency{"TMT", 2}
TMT Turkmenistan manat
var TND = Currency{"TND", 3}
TND Tunisian dinar
var TOP = Currency{"TOP", 2}
TOP Tongan paʻanga
var TRY = Currency{"TRY", 2}
TRY Turkish lira
var TTD = Currency{"TTD", 2}
TTD Trinidad and Tobago dollar
var TWD = Currency{"TWD", 2}
TWD New Taiwan dollar
var TZS = Currency{"TZS", 2}
TZS Tanzanian shilling
var UAH = Currency{"UAH", 2}
UAH Ukrainian hryvnia
var UGX = Currency{"UGX", 0}
UGX Ugandan shilling
var USD = Currency{"USD", 2}
USD United States dollar
var USN = Currency{"USN", 2}
USN United States dollar (next day) (funds code)
var UYI = Currency{"UYI", 0}
UYI Uruguay Peso en Unidades Indexadas (URUIURUI) (funds code)
var UYU = Currency{"UYU", 2}
UYU Uruguayan peso
var UYW = Currency{"UYW", 4}
UYW Unidad previsional[15]
var UZS = Currency{"UZS", 2}
UZS Uzbekistan som
var VES = Currency{"VES", 2}
VES Venezuelan bolívar soberano
var VND = Currency{"VND", 0}
VND Vietnamese đồng
var VUV = Currency{"VUV", 0}
VUV Vanuatu vatu
var WST = Currency{"WST", 2}
WST Samoan tala
var XAF = Currency{"XAF", 0}
XAF CFA franc BEAC
var XAG = Currency{"XAG", 0}
XAG Silver (one troy
var XAU = Currency{"XAU", 0}
XAU Gold (one troy
var XBA = Currency{"XBA", 0}
XBA European Composite Unit (EURCO) (bond market)
var XBB = Currency{"XBB", 0}
XBB European Monetary Unit (E.M.U.-6) (bond market)
var XBC = Currency{"XBC", 0}
XBC European Unit of Account 9 (E.U.A.-9) (bond market)
var XBD = Currency{"XBD", 0}
XBD European Unit of Account 17 (E.U.A.-17) (bond market)
var XCD = Currency{"XCD", 2}
XCD East Caribbean dollar
var XDR = Currency{"XDR", 0}
XDR Special drawing rights
var XOF = Currency{"XOF", 0}
XOF CFA franc BCEAO
var XPD = Currency{"XPD", 0}
XPD Palladium
var XPF = Currency{"XPF", 0}
XPF CFP franc
var XPT = Currency{"XPT", 0}
XPT Platinum
var XSU = Currency{"XSU", 0}
XSU SUCRE
var XTS = Currency{"XTS", 0}
XTS Code reserved for testing
var XUA = Currency{"XUA", 0}
XUA ADB Unit of Account
var XXX = Currency{"XXX", 0}
XXX No currency
var YER = Currency{"YER", 2}
YER Yemeni rial
var ZAR = Currency{"ZAR", 2}
ZAR South African rand
var ZMW = Currency{"ZMW", 2}
ZMW Zambian kwacha
var ZWL = Currency{"ZWL", 2}
ZWL Zimbabwean dollar
Functions ¶
This section is empty.
Types ¶
type Currency ¶
Currency represents an ISO4217 currency
type Money ¶
Money represents a monetary amount
func FromString ¶
FromString returns a Money instance representing the provided amount and currency. It assumes that the input string will have the form: <currency code> <amount> e.g. EUR 1.234
func (Money) Add ¶
Add returns a Money whose amount is the sum of the amounts in this and the other Money instance, if their currencies match. It returns an error if their currencies do not match
func (Money) Compare ¶
Compare compares two Money instances and returns -1, 0, 1 if the first amount is respectively lower than, equal to, or greater than the second one. It returns an error if their currencies don't match.
func (Money) Divide ¶
Divide returns a Money whose amount is the division of the amount in this instance by the provided dividend. It returns an error if the dividend is zero.
func (Money) Equal ¶
Equal compares two Money instances for deep equality, returning true if their amounts and currencies are themselves equal
func (Money) FormattedString ¶
FormattedString returns a string representation of this instance, rounding its amount according to the currency's own precision