aboutsummaryrefslogtreecommitdiffstats
path: root/common/size.go
blob: 80a17279bd6a0d2ec8ba44608183edbd705f79ea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package common

import "fmt"

type StorageSize float64

func (self StorageSize) String() string {
    if self > 1000000 {
        return fmt.Sprintf("%.2f mB", self/1000000)
    } else if self > 1000 {
        return fmt.Sprintf("%.2f kB", self/1000)
    } else {
        return fmt.Sprintf("%.2f B", self)
    }
}