currency

package
v1.33.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Types = []Type{}/* 139 elements not displayed */

Functions

This section is empty.

Types

type Cents

type Cents int64

func CentsFromString

func CentsFromString(s string) Cents

func (Cents) Fake

func (c Cents) Fake() Cents

func (Cents) FakeN

func (c Cents) FakeN(max int) Cents

type Type

type Type string
const (
	USD Type = "usd"
	AUD Type = "aud"
	CAD Type = "cad"
	EUR Type = "eur"
	GBP Type = "gbp"
	HKD Type = "hkd"
	JPY Type = "jpy"
	NZD Type = "nzd"
	SGD Type = "sgd"
	AED Type = "aed" // United Arab Emirates Dirham
	AFN Type = "afn" // Afghan Afghani*
	ALL Type = "all" // Albanian Lek
	AMD Type = "amd" // Armenian Dram
	ANG Type = "ang" // Netherlands Antillean Gulden
	AOA Type = "aoa" // Angolan Kwanza*
	ARS Type = "ars" // Argentine Peso*
	AWG Type = "awg" // Aruban Florin
	AZN Type = "azn" // Azerbaijani Manat
	BAM Type = "bam" // Bosnia & Herzegovina Convertible Mark
	BBD Type = "bbd" // Barbadian Dollar
	BDT Type = "bdt" // Bangladeshi Taka
	BGN Type = "bgn" // Bulgarian Lev
	BIF Type = "bif" // Burundian Franc
	BMD Type = "bmd" // Bermudian Dollar
	BND Type = "bnd" // Brunei Dollar
	BOB Type = "bob" // Bolivian Boliviano*
	BRL Type = "brl" // Brazilian Real*
	BSD Type = "bsd" // Bahamian Dollar
	BWP Type = "bwp" // Botswana Pula
	BZD Type = "bzd" // Belize Dollar
	CDF Type = "cdf" // Congolese Franc
	CHF Type = "chf" // Swiss Franc
	CLP Type = "clp" // Chilean Peso*
	CNY Type = "cny" // Chinese Renminbi Yuan
	COP Type = "cop" // Colombian Peso*
	CRC Type = "crc" // Costa Rican Colón*
	CVE Type = "cve" // Cape Verdean Escudo*
	CZK Type = "czk" // Czech Koruna*
	DJF Type = "djf" // Djiboutian Franc*
	DKK Type = "dkk" // Danish Krone
	DOP Type = "dop" // Dominican Peso
	DZD Type = "dzd" // Algerian Dinar
	EEK Type = "eek" // Estonian Kroon*
	EGP Type = "egp" // Egyptian Pound
	ETB Type = "etb" // Ethiopian Birr
	FJD Type = "fjd" // Fijian Dollar
	FKP Type = "fkp" // Falkland Islands Pound*
	GEL Type = "gel" // Georgian Lari
	GIP Type = "gip" // Gibraltar Pound
	GMD Type = "gmd" // Gambian Dalasi
	GNF Type = "gnf" // Guinean Franc*
	GTQ Type = "gtq" // Guatemalan Quetzal*
	GYD Type = "gyd" // Guyanese Dollar
	HNL Type = "hnl" // Honduran Lempira*
	HRK Type = "hrk" // Croatian Kuna
	HTG Type = "htg" // Haitian Gourde
	HUF Type = "huf" // Hungarian Forint*
	IDR Type = "idr" // Indonesian Rupiah
	ILS Type = "ils" // Israeli New Sheqel
	INR Type = "inr" // Indian Rupee*
	ISK Type = "isk" // Icelandic Króna
	JMD Type = "jmd" // Jamaican Dollar
	KES Type = "kes" // Kenyan Shilling
	KGS Type = "kgs" // Kyrgyzstani Som
	KHR Type = "khr" // Cambodian Riel
	KMF Type = "kmf" // Comorian Franc
	KRW Type = "krw" // South Korean Won
	KYD Type = "kyd" // Cayman Islands Dollar
	KZT Type = "kzt" // Kazakhstani Tenge
	LAK Type = "lak" // Lao Kip*
	LBP Type = "lbp" // Lebanese Pound
	LKR Type = "lkr" // Sri Lankan Rupee
	LRD Type = "lrd" // Liberian Dollar
	LSL Type = "lsl" // Lesotho Loti
	LTL Type = "ltl" // Lithuanian Litas
	LVL Type = "lvl" // Latvian Lats
	MAD Type = "mad" // Moroccan Dirham
	MDL Type = "mdl" // Moldovan Leu
	MGA Type = "mga" // Malagasy Ariary
	MKD Type = "mkd" // Macedonian Denar
	MNT Type = "mnt" // Mongolian Tögrög
	MOP Type = "mop" // Macanese Pataca
	MRO Type = "mro" // Mauritanian Ouguiya
	MUR Type = "mur" // Mauritian Rupee*
	MVR Type = "mvr" // Maldivian Rufiyaa
	MWK Type = "mwk" // Malawian Kwacha
	MXN Type = "mxn" // Mexican Peso*
	MYR Type = "myr" // Malaysian Ringgit
	MZN Type = "mzn" // Mozambican Metical
	NAD Type = "nad" // Namibian Dollar
	NGN Type = "ngn" // Nigerian Naira
	NIO Type = "nio" // Nicaraguan Córdoba*
	NOK Type = "nok" // Norwegian Krone
	NPR Type = "npr" // Nepalese Rupee
	PAB Type = "pab" // Panamanian Balboa*
	PEN Type = "pen" // Peruvian Nuevo Sol*
	PGK Type = "pgk" // Papua New Guinean Kina
	PHP Type = "php" // Philippine Peso
	PKR Type = "pkr" // Pakistani Rupee
	PLN Type = "pln" // Polish Złoty
	PYG Type = "pyg" // Paraguayan Guaraní*
	QAR Type = "qar" // Qatari Riyal
	RON Type = "ron" // Romanian Leu
	RSD Type = "rsd" // Serbian Dinar
	RUB Type = "rub" // Russian Ruble
	RWF Type = "rwf" // Rwandan Franc
	SAR Type = "sar" // Saudi Riyal
	SBD Type = "sbd" // Solomon Islands Dollar
	SCR Type = "scr" // Seychellois Rupee
	SEK Type = "sek" // Swedish Krona
	SHP Type = "shp" // Saint Helenian Pound*
	SLL Type = "sll" // Sierra Leonean Leone
	SOS Type = "sos" // Somali Shilling
	SRD Type = "srd" // Surinamese Dollar*
	STD Type = "std" // São Tomé and Príncipe Dobra
	SVC Type = "svc" // Salvadoran Colón*
	SZL Type = "szl" // Swazi Lilangeni
	THB Type = "thb" // Thai Baht
	TJS Type = "tjs" // Tajikistani Somoni
	TOP Type = "top" // Tongan Paʻanga
	TRY Type = "try" // Turkish Lira
	TTD Type = "ttd" // Trinidad and Tobago Dollar
	TWD Type = "twd" // New Taiwan Dollar
	TZS Type = "tzs" // Tanzanian Shilling
	UAH Type = "uah" // Ukrainian Hryvnia
	UGX Type = "ugx" // Ugandan Shilling
	UYU Type = "uyu" // Uruguayan Peso*
	UZS Type = "uzs" // Uzbekistani Som
	VND Type = "vnd" // Vietnamese Đồng
	VUV Type = "vuv" // Vanuatu Vat
	UWT Type = "uwt" // Samoan Tala
	XAF Type = "xaf" // Central African Cfa Franc
	XCD Type = "xcd" // East Caribbean Dollar
	XOF Type = "xof" // West African Cfa Franc*
	XPF Type = "xpf" // Cfp Franc*
	YER Type = "yer" // Yemeni Rial
	ZAR Type = "zar" // South African Rand
	ZMW Type = "zmw" // Zambian Kwacha

	// Subject to change without reason
	ETH Type = "eth" // Ethereum
	XBT Type = "xbt" // Bitcoin
	BTC Type = "btc" // Old bitcoin

	PNT Type = "points" // points
)

func Fake

func Fake() Type

func (Type) Code

func (t Type) Code() string

Give the currency's Code

func (Type) FromMinimalUnits

func (t Type) FromMinimalUnits(b *big.Int) Cents

func (Type) IsCrypto

func (t Type) IsCrypto() bool

Is this a supported cryptocurrency

func (Type) IsZeroDecimal

func (t Type) IsZeroDecimal() bool

Does the currency not have a decimal convention such as Japanese Yen (¥100) instead of USD ($1.00)

func (Type) Label

func (t Type) Label() string

Give the currency's Symbol + Code string

func (Type) MinimalUnitFactor

func (t Type) MinimalUnitFactor() *big.Int

Since pricing things in a crypto minimal denomination exceed int64 and the minimal domination is worth so little, we generally use a larger denomination of the currency by convention that can capture the minimal relatable values.

This returns the ratio of convention denomination to minimal denomination

func (Type) Symbol

func (t Type) Symbol() string

Give the currency's symbol

func (Type) ToFloat

func (t Type) ToFloat(c Cents) float64

Convert to float representation based on decimal convention

func (Type) ToMinimalUnits

func (t Type) ToMinimalUnits(c Cents) *big.Int

func (Type) ToString

func (t Type) ToString(c Cents) string

Stringifies currency with symbol

func (Type) ToStringNoSymbol

func (t Type) ToStringNoSymbol(c Cents) string

Stringifies currency with no

Jump to

Keyboard shortcuts

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