mathutil

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2021 License: MIT Imports: 7 Imported by: 28

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConvertFail = errors.New("convert data type is failure")
)

Functions

func DataSize

func DataSize(size uint64) string

DataSize format value. alias format.DataSize()

func ElapsedTime

func ElapsedTime(startTime time.Time) string

ElapsedTime calc elapsed time 计算运行时间消耗 单位 ms(毫秒)

func Float added in v0.2.2

func Float(in interface{}) (float64, error)

Float convert value to float64

func HowLongAgo

func HowLongAgo(sec int64) string

HowLongAgo calc time. alias format.HowLongAgo()

func Int added in v0.2.2

func Int(in interface{}) (int, error)

Int convert string to int

func Int64 added in v0.2.2

func Int64(in interface{}) (int64, error)

Int64 convert string to int64

func IsNumeric added in v0.3.12

func IsNumeric(c byte) bool

IsNumeric returns true if the given character is a numeric, otherwise false.

func MustFloat added in v0.2.2

func MustFloat(in interface{}) float64

MustFloat convert value to float64

func MustInt added in v0.2.2

func MustInt(in interface{}) int

MustInt convert string to int

func MustInt64 added in v0.2.2

func MustInt64(in interface{}) int64

MustInt64 convert

func MustUint added in v0.2.2

func MustUint(in interface{}) uint64

MustUint convert string to uint

func Percent

func Percent(val, total int) float64

Percent returns a values percent of the total

func RandomInt added in v0.3.6

func RandomInt(min, max int) int

RandomInt return an random int at the min ~ max Usage:

RandomInt(10, 99)
RandomInt(100, 999)
RandomInt(1000, 9999)

func ToFloat added in v0.2.2

func ToFloat(in interface{}) (f64 float64, err error)

ToFloat convert value to float64

func ToInt added in v0.2.2

func ToInt(in interface{}) (iVal int, err error)

ToInt convert string to int

func ToInt64 added in v0.2.2

func ToInt64(in interface{}) (i64 int64, err error)

ToInt64 convert string to int64

func ToUint added in v0.2.2

func ToUint(in interface{}) (u64 uint64, err error)

ToUint convert string to uint

func Uint added in v0.2.2

func Uint(in interface{}) (uint64, error)

Uint convert string to uint

Types

This section is empty.

Jump to

Keyboard shortcuts

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