vndr units to 6950e57

Signed-off-by: Andrew Hsu <andrewhsu@docker.com>
This commit is contained in:
Andrew Hsu
2018-08-14 06:22:59 +00:00
parent 094ed67122
commit bb983ee75b
2 changed files with 10 additions and 2 deletions

View File

@ -67,7 +67,7 @@ func (b Bytes) Format(f fmt.State, c rune) {
case 'f', 'g':
fv, unit, ok := b.floatValue(f.Flag('#'))
if !ok {
b.formatInt(f, 'd', true)
b.formatInt(&noPrecision{f}, 'd', true)
return
}
big.NewFloat(fv).Format(f, c)
@ -115,3 +115,11 @@ func (b Bytes) floatValue(binary bool) (float64, string, bool) {
return float64(b) / math.Abs(float64(baseUnit)), units[binary][i], true
}
}
type noPrecision struct {
fmt.State
}
func (*noPrecision) Precision() (prec int, ok bool) {
return 0, false
}