Documentation
¶
Index ¶
- Constants
- Variables
- func GetDefaultJSONDecimals() int
- func SetDefaultJSONDecimals(decimals int)
- type Money
- func (m Money) Abs() Money
- func (m Money) Add(x Money) Money
- func (m Money) Cmp(x Money) int
- func (m Money) DivInt(n int64) Money
- func (m Money) Float64() float64
- func (m Money) FormatDecimals(decimals int) string
- func (Money) GormDBDataType(db *gorm.DB, field *schema.Field) string
- func (Money) GormDataType() string
- func (m Money) Greater(x Money) bool
- func (m Money) Int64() int64
- func (m Money) IsNegative() bool
- func (m Money) IsZero() bool
- func (m Money) Less(x Money) bool
- func (m Money) MarshalJSON() ([]byte, error)
- func (m Money) MarshalJSONWithDecimals(decimals int) ([]byte, error)
- func (m Money) MulInt(n int64) Money
- func (m Money) MulRate(rate int64) Money
- func (m Money) MulRatio(numerator, denominator int64) Money
- func (m Money) SafeAdd(x Money) (Money, error)
- func (m *Money) Scan(value any) error
- func (m Money) String() string
- func (m Money) StringFixed(decimals int) string
- func (m Money) Sub(x Money) Money
- func (m *Money) UnmarshalJSON(data []byte) error
- func (m Money) Value() (driver.Value, error)
- type MoneyJSON
Constants ¶
View Source
const ( MoneyScale = 8 MoneyBase = int64(100000000) )
Variables ¶
View Source
var ZeroMoney = Money{}
Functions ¶
func GetDefaultJSONDecimals ¶
func GetDefaultJSONDecimals() int
GetDefaultJSONDecimals 获取默认 JSON 输出小数位数
func SetDefaultJSONDecimals ¶
func SetDefaultJSONDecimals(decimals int)
SetDefaultJSONDecimals 设置默认 JSON 输出小数位数 decimals: 0 表示输出所有非零小数位,1-8 表示保留指定位数
Types ¶
type Money ¶
type Money struct {
// contains filtered or unexported fields
}
func (Money) FormatDecimals ¶
FormatDecimals 按指定小数位格式化 decimals: 0 表示输出所有非零小数位,1-8 表示保留指定位数
func (Money) GormDataType ¶
func (Money) IsNegative ¶
func (Money) MarshalJSON ¶
func (Money) MarshalJSONWithDecimals ¶
func (Money) StringFixed ¶
func (*Money) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.