money

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2021 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 an amount with precision 2

  • 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) Ceil added in v0.6.0

func (m Money) Ceil() Money

Ceil is like 'math.Ceil'

func (Money) Div added in v0.6.0

func (m Money) Div(n int64) Money

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

func (Money) Float added in v0.6.0

func (m Money) Float() float64

Float converts Money to float64

func (Money) Floor added in v0.6.0

func (m Money) Floor() Money

Floor is like 'math.Floor'

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) Int added in v0.6.0

func (m Money) Int() int64

Int converts Money to int64

func (Money) MarshalJSON

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

func (Money) Round added in v0.6.0

func (m Money) Round() Money

Round is like 'math.Round'

func (Money) String added in v0.6.0

func (m Money) String() string

String 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) Sub

func (m Money) Sub(sub Money) Money

Sub returns remainder after subtraction

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