money

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 31, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCurrency

func AddCurrency(c Currency)

AddCurrency will add a currency to the list of currencies you can search for.

Types

type Currency

type Currency interface {
	// NumericCode returns the ISO numeric currency code as a string, e.g. "840"
	NumericCode() string

	// DecimalDigits returns the number of decimal digits used by the currency
	DecimalDigits() int

	// String returns the ISO alphabetic currency code, e.g. "GBP"
	String() string
}

Currency represents a monetary currency

func FindCurrency

func FindCurrency(code string) Currency

FindCurrency will return a currency based on the currency code (numeric or alpha)

func NewCurrency

func NewCurrency(alphaCode, numericCode string, decimalDigits int) Currency

NewCurrency constructs a currency object

type Money

type Money interface {
	// String returns the string value of the money value, with appropriate number of decimal digits.
	String() string

	// Currency returns the currency used by this amount
	Currency() Currency
}

Money represents a monetary amount

func NewMoney

func NewMoney(amount string, c Currency) (Money, error)

NewMoney constructs a Money object from the amount string and the currency.

Jump to

Keyboard shortcuts

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