Files
weave-scope/vendor/github.com/alecthomas/units/si.go
Marc CARRE c9d53ef8be Add weaveworks/promrus v1.1.0.
```
$ gvt fetch -tag v1.1.0 github.com/weaveworks/promrus
2017/10/08 XX:XX:XX Fetching: github.com/weaveworks/promrus
2017/10/08 XX:XX:XX · Fetching recursive dependency: github.com/julienschmidt/httprouter
2017/10/08 XX:XX:XX · Fetching recursive dependency: github.com/go-kit/kit/log
2017/10/08 XX:XX:XX ·· Fetching recursive dependency: github.com/go-stack/stack
2017/10/08 XX:XX:XX ·· Fetching recursive dependency: github.com/go-logfmt/logfmt
2017/10/08 XX:XX:XX ··· Fetching recursive dependency: github.com/kr/logfmt
2017/10/08 XX:XX:XX · Skipping (existing): gopkg.in/yaml.v2
2017/10/08 XX:XX:XX · Fetching recursive dependency: gopkg.in/alecthomas/kingpin.v2
2017/10/08 XX:XX:XX ·· Fetching recursive dependency: github.com/alecthomas/units
2017/10/08 XX:XX:XX ·· Fetching recursive dependency: github.com/alecthomas/template
2017/10/08 XX:XX:XX · Skipping (existing): golang.org/x/net/context/ctxhttp
2017/10/08 XX:XX:XX · Fetching recursive dependency: github.com/stretchr/objx
2017/10/08 XX:XX:XX · Skipping (existing): golang.org/x/net/context
2017/10/08 XX:XX:XX · Fetching recursive dependency: github.com/pkg/errors
```
2017-10-08 18:37:28 +01:00

27 lines
650 B
Go

package units
// SI units.
type SI int64
// SI unit multiples.
const (
Kilo SI = 1000
Mega = Kilo * 1000
Giga = Mega * 1000
Tera = Giga * 1000
Peta = Tera * 1000
Exa = Peta * 1000
)
func MakeUnitMap(suffix, shortSuffix string, scale int64) map[string]float64 {
return map[string]float64{
shortSuffix: 1,
"K" + suffix: float64(scale),
"M" + suffix: float64(scale * scale),
"G" + suffix: float64(scale * scale * scale),
"T" + suffix: float64(scale * scale * scale * scale),
"P" + suffix: float64(scale * scale * scale * scale * scale),
"E" + suffix: float64(scale * scale * scale * scale * scale * scale),
}
}