money

package
v0.0.0-...-72f4496 Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidValue        = errors.New("one of the specified money values is invalid")
	ErrMismatchingCurrency = errors.New("mismatching currency codes")
)

Functions

func AreEquals

func AreEquals(l, r pb.Money) bool

AreEquals returns true if values l and r are the equal, including the currency. This does not check validity of the provided values.

func AreSameCurrency

func AreSameCurrency(l, r pb.Money) bool

AreSameCurrency returns true if values l and r have a currency code and they are the same values.

func IsNegative

func IsNegative(m pb.Money) bool

IsNegative returns true if the specified money value is valid and is negative.

func IsPositive

func IsPositive(m pb.Money) bool

IsPositive returns true if the specified money value is valid and is positive.

func IsValid

func IsValid(m pb.Money) bool

IsValid checks if specified value has a valid units/nanos signs and ranges.

func IsZero

func IsZero(m pb.Money) bool

IsZero returns true if the specified money value is equal to zero.

func MultiplySlow

func MultiplySlow(m pb.Money, n uint32) pb.Money

MultiplySlow is a slow multiplication operation done through adding the value to itself n-1 times.

func Must

func Must(v pb.Money, err error) pb.Money

Must panics if the given error is not nil. This can be used with other functions like: "m := Must(Sum(a,b))".

func Negate

func Negate(m pb.Money) pb.Money

Negate returns the same amount with the sign negated.

func Sum

func Sum(l, r pb.Money) (pb.Money, error)

Sum adds two values. Returns an error if one of the values are invalid or currency codes are not matching (unless currency code is unspecified for both).

Types

This section is empty.

Jump to

Keyboard shortcuts

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