Files
scrutiny/vendor/github.com/jaypipes/ghw/units.go
T
2020-08-21 06:31:48 +00:00

34 lines
565 B
Go

//
// Use and distribution licensed under the Apache license version 2.
//
// See the COPYING file in the root project directory for full text.
//
package ghw
var (
KB int64 = 1024
MB = KB * 1024
GB = MB * 1024
TB = GB * 1024
PB = TB * 1024
EB = PB * 1024
)
func unitWithString(size int64) (int64, string) {
switch {
case size < MB:
return KB, "KB"
case size < GB:
return MB, "MB"
case size < TB:
return GB, "GB"
case size < PB:
return TB, "TB"
case size < EB:
return PB, "PB"
default:
return EB, "EB"
}
}