23 lines
403 B
Go
23 lines
403 B
Go
|
package utils
|
||
|
|
||
|
import (
|
||
|
"github.com/dustin/go-humanize"
|
||
|
"math/big"
|
||
|
)
|
||
|
|
||
|
type flowCalculation struct{}
|
||
|
|
||
|
func FlowCalculation() flowCalculation {
|
||
|
return flowCalculation{}
|
||
|
}
|
||
|
|
||
|
// Parse
|
||
|
// @description: 解析流量,序列化为字符串
|
||
|
// @receiver flowCalculation
|
||
|
// @param b
|
||
|
// @return string
|
||
|
func (flowCalculation) Parse(b int64) string {
|
||
|
b2 := big.Int{}
|
||
|
return humanize.BigBytes(b2.SetInt64(b))
|
||
|
}
|