mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
add byte formatting for tb
This commit is contained in:
parent
fb39d69fa7
commit
c1780ae30a
@ -9,6 +9,7 @@ const (
|
||||
kb = 1024
|
||||
mb = kb * 1024
|
||||
gb = mb * 1024
|
||||
tb = gb * 1024
|
||||
)
|
||||
|
||||
// convenience method
|
||||
@ -28,8 +29,12 @@ func ByteFormat(n int64) string {
|
||||
n = n / mb
|
||||
return fmt.Sprintf("%sM", strconv.FormatInt(n, 10))
|
||||
}
|
||||
nf := float64(n) / gb
|
||||
return fmt.Sprintf("%sG", unpadFloat(nf))
|
||||
if n < tb {
|
||||
nf := float64(n) / gb
|
||||
return fmt.Sprintf("%sG", unpadFloat(nf))
|
||||
}
|
||||
nf := float64(n) / tb
|
||||
return fmt.Sprintf("%sT", unpadFloat(nf))
|
||||
}
|
||||
|
||||
func unpadFloat(f float64) string {
|
||||
|
Loading…
Reference in New Issue
Block a user