mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-06 03:31:00 +00:00
Upgraded from 99c19923, branch release-3.0. This required fetching or upgrading the following: * k8s.io/api to kubernetes-1.9.1 * k8s.io/apimachinery to kubernetes-1.9.1 * github.com/juju/ratelimit to 1.0.1 * github.com/spf13/pflag to 4c012f6d Also, update Scope's imports/function calls to be compatible with the new client.
46 lines
835 B
Go
46 lines
835 B
Go
// Copyright 2009 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package appstats
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
type byteSize float64
|
|
|
|
const (
|
|
_ = iota
|
|
_KB byteSize = 1 << (10 * iota)
|
|
_MB
|
|
_GB
|
|
_TB
|
|
_PB
|
|
_EB
|
|
_ZB
|
|
_YB
|
|
)
|
|
|
|
func (b byteSize) String() string {
|
|
switch {
|
|
case b >= _YB:
|
|
return fmt.Sprintf("%.2fYB", b/_YB)
|
|
case b >= _ZB:
|
|
return fmt.Sprintf("%.2fZB", b/_ZB)
|
|
case b >= _EB:
|
|
return fmt.Sprintf("%.2fEB", b/_EB)
|
|
case b >= _PB:
|
|
return fmt.Sprintf("%.2fPB", b/_PB)
|
|
case b >= _TB:
|
|
return fmt.Sprintf("%.2fTB", b/_TB)
|
|
case b >= _GB:
|
|
return fmt.Sprintf("%.2fGB", b/_GB)
|
|
case b >= _MB:
|
|
return fmt.Sprintf("%.2fMB", b/_MB)
|
|
case b >= _KB:
|
|
return fmt.Sprintf("%.2fKB", b/_KB)
|
|
}
|
|
return fmt.Sprintf("%.2fB", b)
|
|
}
|