currency

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2021 License: MIT Imports: 3 Imported by: 0

README

currency

Currency abstractions for Golang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(currencies ...Currency)

Add registers new currency in global currencies registry

Types

type Amount

type Amount interface {
	Currency() Short
	Amount() float64
}

Amount contains amount

type Currency

type Currency struct {
	Numeric  string // ISO 4217 numeric currency code
	ISO      string // ISO currency code
	Name     string // Currency name
	Decimals int    // Amount of decimals
}

Currency contains full information about currency

func ByISO

func ByISO(s string) (Currency, bool)

ByISO searches for currency by ISO code

func ByNumeric

func ByNumeric(s string) (Currency, bool)

ByNumeric searches for currency by numeric code

func EUR

func EUR() Currency

EUR returns EUR currency

func Testing

func Testing() Currency

Testing returns testing currency (XTS)

func USD

func USD() Currency

USD returns USD currency

func (Currency) Short

func (c Currency) Short() Short

Short returns short (brief) representation of currency

func (Currency) String

func (c Currency) String() string

type Rate

type Rate struct {
	From Short
	To   Short
	Rate float32
	Time time.Time
}

Rate contains currency exchange rate

func (Rate) String

func (r Rate) String() string

type Short

type Short struct {
	Numeric  string // ISO 4217 numeric currency code
	ISO      string // ISO currency code
	Decimals int    // Amount of decimals
}

Short contains short (brief) currency configuration

func (Short) String

func (s Short) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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