Documentation ¶
Index ¶
- Variables
- func Calculator(exp string) (string, error)
- func CheckNumStrInRange(s string, min float64, max float64) (bool, error)
- func DecimalFormatBanker(value decimal.Decimal) string
- func FormatNumStrToDecimalAndShift(number string, decimals uint) decimal.Decimal
- func GetMaxNum(vals ...int) int
- func HashIdToInt64(id string, minLen uint8) (int64, error)
- func Int64ToHashId(number int64, minLen uint8) string
- func MergeToDecimal(number *big.Int, dec int) decimal.Decimal
- func StrToDecimalTruncate(s string, precision int32) (decimal.Decimal, error)
- func ValidateSecPwd(secPwd string) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidSecPwdLength = errors.New("security password must be 6 digits") ErrInvalidSecPwdConsecutive = errors.New("security password must not contain three consecutive numbers") ErrEmptyID = errors.New("id is empty") ErrInvalidHashID = errors.New("decoded hash id is invalid") ErrParseFloat = errors.New("unable to parse string to float") ErrDecimalConversion = errors.New("unable to convert string to decimal") )
定义常见错误消息
Functions ¶
func Calculator ¶ added in v1.8.68
Calculator 输入字符串数学表达式,将计算出结果
func CheckNumStrInRange ¶ added in v1.8.68
CheckNumStrInRange 检查一个字符串数字,大小是否在指定的范围内
func DecimalFormatBanker ¶ added in v1.8.68
DecimalFormatBanker 使用银行家舍入法格式化decimal类型值为两位小数
func FormatNumStrToDecimalAndShift ¶ added in v1.8.68
FormatNumStrToDecimalAndShift 输入1000,4 ,那么会输出 0.1
func HashIdToInt64 ¶ added in v1.8.68
HashIdToInt64 将 hash ID 转换为 int64
func Int64ToHashId ¶ added in v1.8.68
Int64ToHashId 将 int64 转换为 Sqids 编码的 hash ID
func MergeToDecimal ¶ added in v1.8.68
MergeToDecimal 如果输入的number是100000,dec是10,那么:将100000的小数点向左移动10位,得到的结果是0.00001
func StrToDecimalTruncate ¶ added in v1.8.68
StrToDecimalTruncate 将字符串数字变成decimal类型,保留指定小数位数,多余的全部放弃,不做四舍五入
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.