Documentation
¶
Index ¶
- type CAD
- func CADCanonicalForm(dollars int32, cents int8) CAD
- func CADCent() CAD
- func CADCents(value int64) CAD
- func CADDime() CAD
- func CADDollar() CAD
- func CADDollars(value int64) CAD
- func CADEightBits() CAD
- func CADFourBits() CAD
- func CADNickel() CAD
- func CADQuarter() CAD
- func CADSixBits() CAD
- func CADTwoBits() CAD
- func MustParseCAD(str string) CAD
- func ParseCAD(str string) (CAD, error)
- func (m CAD) Abs() CAD
- func (m CAD) Add(val CAD) CAD
- func (m CAD) CanonicalForm() (dollars int64, cents int64, something bool)
- func (m CAD) Format(layout string) string
- func (m CAD) GoString() string
- func (m CAD) MarshalJSON() ([]byte, error)
- func (m CAD) Mul(scalar int64) CAD
- func (m *CAD) Scan(src interface{}) error
- func (m CAD) String() string
- func (m CAD) Sub(other CAD) CAD
- func (m *CAD) UnmarshalJSON(src []byte) error
- func (m CAD) Value() (driver.Value, error)
- type USD
- func MustParseUSD(str string) USD
- func ParseUSD(str string) (USD, error)
- func USDCanonicalForm(dollars int32, cents int8) USD
- func USDCent() USD
- func USDCents(value int64) USD
- func USDDime() USD
- func USDDollar() USD
- func USDDollars(value int64) USD
- func USDEightBits() USD
- func USDFourBits() USD
- func USDNickel() USD
- func USDQuarter() USD
- func USDSixBits() USD
- func USDTwoBits() USD
- func (m USD) Abs() USD
- func (m USD) Add(val USD) USD
- func (m USD) CanonicalForm() (dollars int64, cents int64, something bool)
- func (m USD) Format(layout string) string
- func (m USD) GoString() string
- func (m USD) MarshalJSON() ([]byte, error)
- func (m USD) Mul(scalar int64) USD
- func (m *USD) Scan(src interface{}) error
- func (m USD) String() string
- func (m USD) Sub(other USD) USD
- func (m *USD) UnmarshalJSON(src []byte) error
- func (m USD) Value() (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CAD ¶
type CAD struct {
// contains filtered or unexported fields
}
CAD represents a Canadian Dollar amount.
Note that CAD is an option-type, and thus its uninitialized form is nothing (and not zero).
func CADCanonicalForm ¶
CADCanonicalForm takes a dollars, and cents amount and returns a money.CAD with that amount.
For example:
var value money.CAD = money.CADCanonicalForm(123, 45)
This will return $123.45
func CADDollars ¶
func CADEightBits ¶
func CADEightBits() CAD
CADEightBits returns eight-bits in Canadian Dollars.
Eight-bits means 100¢ (i.e., $1.00).
A bit means ⅛ of a dollar. And thus eight-bits is 1 dollar (i.e., 100¢ or $1.00).
func CADFourBits ¶
func CADFourBits() CAD
USDFourBits returns four-bits in U.S. Dollars.
Four-bits means 50¢ (i.e., $0.50).
A bit means ⅛ of a dollar. And thus four-bits is ½ of a dollar (i.e., 50¢ or $0.50).
func CADQuarter ¶
func CADQuarter() CAD
func CADSixBits ¶
func CADSixBits() CAD
CADSixBits returns six-bits in Canadian Dollars.
Six-bits means 75¢ (i.e., $0.75).
A bit means ⅛ of a dollar. And thus six-bits is ¾ of a dollar (i.e., 75¢ or $0.75).
func CADTwoBits ¶
func CADTwoBits() CAD
CADTwoBits returns two-bits in Canadian Dollars.
Two-bits means 25¢ (i.e., $0.25).
A bit means ⅛ of a dollar. And thus two-bits is ¼ of a dollar (i.e., 25¢ or $0.25).
func MustParseCAD ¶
MustParseCAD converts a string to a CAD, but panic()s if there is an error.
func (CAD) CanonicalForm ¶
func (CAD) Format ¶
Format returns a textual representation of the CAD money value formatted according to layout.
Options for layout include:
"$"
$123.45
"\uFE69" or "﹩"
﹩123.45
"\uFF04" or "$"
$123.45
"\U0001F4B2" or "💲"
💲123.45
"\u00A2" or "¢"
12345¢
"\uFFE0" or "¢"
12345¢
"-12345.67"
-9876543.21
"-12345,67"
-9876543,21
"-12,345.67"
-9,876,543.21
"-12.345,67"
-9.876.543,21
"-1234567"
-987654321
"-1,234,567"
-987,654,321
"-1.234.567"
-987.654.321
func (CAD) GoString ¶
GoString returns a money.CAD in a Go code representation; ex: "money.USDCents(1234)".
func (CAD) MarshalJSON ¶
MarshalJSON is to make it so money.CAD fits the json.Marshaler interface.
func (*CAD) UnmarshalJSON ¶
UnmarshalJSON is to make it so money.CAD fits the json.Marshaler interface.
type USD ¶
type USD struct {
// contains filtered or unexported fields
}
USD represents a U.S. Dollar amount.
Note that USD is an option-type, and thus its uninitialized form is nothing (and not zero).
func MustParseUSD ¶
MustParseUSD converts a string to a USD, but panic()s if there is an error.
func USDCanonicalForm ¶
USDCanonicalForm takes a dollars, and cents amount and returns a money.USD with that amount.
For example:
var value money.USD = money.USDCanonicalForm(123, 45)
This will return $123.45
func USDDollars ¶
func USDEightBits ¶
func USDEightBits() USD
USDEightBits returns eight-bits in U.S. Dollars.
Eight-bits means 100¢ (i.e., $1.00).
A bit means ⅛ of a dollar. And thus eight-bits is 1 dollar (i.e., 100¢ or $1.00).
func USDFourBits ¶
func USDFourBits() USD
CADFourBits returns four-bits in U.S. Dollars.
Four-bits means 50¢ (i.e., $0.50).
A bit means ⅛ of a dollar. And thus four-bits is ½ of a dollar (i.e., 50¢ or $0.50).
func USDQuarter ¶
func USDQuarter() USD
func USDSixBits ¶
func USDSixBits() USD
USDSixBits returns six-bits in U.S. Dollars.
Six-bits means 75¢ (i.e., $0.75).
A bit means ⅛ of a dollar. And thus six-bits is ¾ of a dollar (i.e., 75¢ or $0.75).
func USDTwoBits ¶
func USDTwoBits() USD
CADTwoBits returns two-bits in U.S. Dollars.
Two-bits means 25¢ (i.e., $0.25).
A bit means ⅛ of a dollar. And thus two-bits is ¼ of a dollar (i.e., 25¢ or $0.25).
func (USD) CanonicalForm ¶
func (USD) Format ¶
Format returns a textual representation of the USD money value formatted according to layout.
Options for layout include:
"$"
$123.45
"\uFE69" or "﹩"
﹩123.45
"\uFF04" or "$"
$123.45
"\U0001F4B2" or "💲"
💲123.45
"\u00A2" or "¢"
12345¢
"\uFFE0" or "¢"
12345¢
"-12345.67"
-9876543.21
"-12345,67"
-9876543,21
"-12,345.67"
-9,876,543.21
"-12.345,67"
-9.876.543,21
"-1234567"
-987654321
"-1,234,567"
-987,654,321
"-1.234.567"
-987.654.321
func (USD) GoString ¶
GoString returns a money.USD in a Go code representation; ex: "money.USDCents(1234)".
func (USD) MarshalJSON ¶
MarshalJSON is to make it so money.USD fits the json.Marshaler interface.
func (*USD) UnmarshalJSON ¶
UnmarshalJSON is to make it so money.USD fits the json.Marshaler interface.
Source Files
¶
- canonicalform.go
- cent.go
- cents.go
- dime.go
- dollar.go
- dollars.go
- eightbits.go
- fourbits.go
- money.go
- money_abs.go
- money_add.go
- money_canonicalform.go
- money_format.go
- money_gostring.go
- money_marshal_json.go
- money_mul.go
- money_scan.go
- money_string.go
- money_sub.go
- money_unmarshal_json.go
- money_value.go
- nickel.go
- nothing.go
- parse.go
- quarter.go
- readable.go
- sixbits.go
- twobits.go