fix: pretty bytes with Tb.

This commit is contained in:
Daniel Ding
2026-01-11 20:46:34 +08:00
parent 32039aaa89
commit 74d282435b
2 changed files with 6 additions and 2 deletions
+1 -1
View File
@@ -210,7 +210,7 @@ func ListPhyLinks() []Device {
State: state,
Drop: attr.Statistics.RxDropped,
Recv: attr.Statistics.RxBytes,
Send: attr.Statistics.TxPackets,
Send: attr.Statistics.TxBytes,
Type: t,
})
}
+5 -1
View File
@@ -248,7 +248,11 @@ func PrettyBytes(b uint64) string {
return fmt.Sprintf("%d.%02dMb", m, d)
}
g, d := split(m, 1024)
return fmt.Sprintf("%d.%02dGb", g, d)
if g < 1024 {
return fmt.Sprintf("%d.%02dGb", g, d)
}
t, d := split(g, 1024)
return fmt.Sprintf("%d.%02dTb", t, d)
}
func GetIPAddr(addr string) string {