Documentation ¶
Overview ¶
Package money represents money values with no loss in precision and without rounding errors.
Index ¶
- type Money
- func (m *Money) Add(other *Money) *Money
- func (m *Money) AddTaxPercent(tax int64) *Money
- func (m *Money) Cents() int64
- func (m *Money) Display(currency string) string
- func (m *Money) Div(other *Money) *Money
- func (m *Money) Format(prec int) string
- func (m *Money) FormatHuman(prec int) string
- func (m *Money) IsZero() bool
- func (m *Money) LessThan(other *Money) bool
- func (m *Money) Mul(n int64) *Money
- func (m *Money) Sub(other *Money) *Money
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Money ¶
type Money struct {
// contains filtered or unexported fields
}
Money represents a monetary value
func NewFromCents ¶
NewFromCents creates a new instance with a cents value.
func Parse ¶
Parse a string to create a new money value. It can read `XX.YY` and `XX,YY`. An empty string is parsed as zero.
func (*Money) AddTaxPercent ¶
AddTaxPercent adds a percentage of the price to itself.
func (*Money) FormatHuman ¶ added in v1.53.2
Format the money value with a specific decimal precision and thousands separator.
Click to show internal directories.
Click to hide internal directories.