coin

package
v3.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const CoinScale = 8

========================================== 常量与基数 ==========================================

Variables

This section is empty.

Functions

This section is empty.

Types

type CoinMoney

type CoinMoney struct {
	// contains filtered or unexported fields
}

========================================== CoinMoney 结构体 内部使用 big.Int 存储最小单位(固定 8 位小数) ==========================================

func FromInt

func FromInt(v *big.Int) CoinMoney

func FromInt64

func FromInt64(v int64) CoinMoney

func FromToken

func FromToken(token *big.Int, decimals uint8) CoinMoney

TokenAmount → CoinMoney decimals: ERC20 decimals

func ParseCoinMoney

func ParseCoinMoney(s string) (CoinMoney, error)

ParseCoinMoney 从字符串解析,例如 "123.45678901"

func Zero

func Zero() CoinMoney

========================================== 构造函数 ==========================================

func (CoinMoney) Abs

func (m CoinMoney) Abs() CoinMoney

func (CoinMoney) Add

func (m CoinMoney) Add(x CoinMoney) CoinMoney

========================================== 基础运算 ==========================================

func (CoinMoney) Cmp

func (m CoinMoney) Cmp(x CoinMoney) int

func (CoinMoney) DivInt

func (m CoinMoney) DivInt(n int64) CoinMoney

func (CoinMoney) DivIntExact

func (m CoinMoney) DivIntExact(n int64) (CoinMoney, error)

精确除法(必须整除)

func (CoinMoney) GormDBDataType

func (m CoinMoney) GormDBDataType(db *gorm.DB, field *schema.Field) string

========================================== GORM / SQL ==========================================

func (CoinMoney) Int

func (m CoinMoney) Int() *big.Int

func (CoinMoney) IsNegative

func (m CoinMoney) IsNegative() bool

func (CoinMoney) IsZero

func (m CoinMoney) IsZero() bool

func (CoinMoney) MarshalJSON

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

========================================== JSON ==========================================

func (CoinMoney) MulInt

func (m CoinMoney) MulInt(n int64) CoinMoney

func (*CoinMoney) Scan

func (m *CoinMoney) Scan(value any) error

func (CoinMoney) String

func (m CoinMoney) String() string

========================================== 输出 ==========================================

func (CoinMoney) Sub

func (m CoinMoney) Sub(x CoinMoney) CoinMoney

func (CoinMoney) ToToken

func (m CoinMoney) ToToken(decimals uint8) (*big.Int, error)

CoinMoney → TokenAmount

func (*CoinMoney) UnmarshalJSON

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

func (CoinMoney) Value

func (m CoinMoney) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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