:new:完成客户端链接状态监控

This commit is contained in:
coward
2024-03-15 15:17:40 +08:00
parent d50f17ed12
commit 30cc35ae00
8 changed files with 115 additions and 3 deletions

22
utils/flow_calculation.go Normal file
View File

@@ -0,0 +1,22 @@
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))
}

View File

@@ -0,0 +1,11 @@
package utils
import (
"fmt"
"testing"
)
func TestParse(t *testing.T) {
f := FlowCalculation()
fmt.Println(f.Parse(13030000000))
}