money

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Money

type Money int64

Money is a sum of money multiplied by precision (100). It can be negative Money is marshalled without multiplication:

  • FromInt(15) -> 15
  • FromFloat(15.07) -> 15.07
  • FromFloat(15.073) -> 15.07
  • FromFloat(15.078) -> 15.07

func FromFloat

func FromFloat(m float64) Money

FromFloat converts float64 to Money

func FromInt

func FromInt(m int64) Money

FromInt converts int64 to Money

func (Money) Add

func (m Money) Add(add Money) Money

Add returns sum of original and passed Moneys

func (Money) AddFloat

func (m Money) AddFloat(add float64) Money

AddFloat returns sum of original money and passed float64

func (Money) AddInt

func (m Money) AddInt(add int64) Money

AddInt returns sum of original money and passed int64

func (Money) Divide

func (m Money) Divide(n int64) Money

Divide divides Money by n (if n <= 0, it panics)

func (Money) Format

func (m Money) Format(f fmt.State, c rune)

Format implements 'fmt.Formatter' interface. It divides a number in groups of three didits separated by thin space

func (Money) MarshalJSON

func (m Money) MarshalJSON() ([]byte, error)

func (Money) Sub

func (m Money) Sub(sub Money) Money

Sub returns remainder after subtraction

func (Money) SubFloat

func (m Money) SubFloat(sub float64) Money

SubFloat returns remainder after subtraction

func (Money) SubInt

func (m Money) SubInt(sub int64) Money

SubInt returns remainder after subtraction

func (Money) ToFloat

func (m Money) ToFloat() float64

ToInt converts Money to float64

func (Money) ToInt

func (m Money) ToInt() int64

ToInt converts Money to int64

func (Money) ToString

func (m Money) ToString() string

ToString converts Money to string. Money is always formatted as a number with 2 digits after decimal point (123.45, 123.00 and etc.)

func (*Money) UnmarshalJSON

func (m *Money) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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