mirror of
https://github.com/minio/minio.git
synced 2025-11-10 22:10:12 -05:00
vendorize: update all vendorized packages. (#2206)
Bring in new changes from upstream for all the packages. Important ones include - gorilla/mux - logrus - jwt
This commit is contained in:
13
vendor/github.com/dustin/go-humanize/si.go
generated
vendored
13
vendor/github.com/dustin/go-humanize/si.go
generated
vendored
@@ -41,7 +41,7 @@ func revfmap(in map[float64]string) map[string]float64 {
|
||||
var riParseRegex *regexp.Regexp
|
||||
|
||||
func init() {
|
||||
ri := `^([0-9.]+)([`
|
||||
ri := `^([\-0-9.]+)\s?([`
|
||||
for _, v := range siPrefixTable {
|
||||
ri += v
|
||||
}
|
||||
@@ -61,18 +61,21 @@ func ComputeSI(input float64) (float64, string) {
|
||||
if input == 0 {
|
||||
return 0, ""
|
||||
}
|
||||
exponent := math.Floor(logn(input, 10))
|
||||
mag := math.Abs(input)
|
||||
exponent := math.Floor(logn(mag, 10))
|
||||
exponent = math.Floor(exponent/3) * 3
|
||||
|
||||
value := input / math.Pow(10, exponent)
|
||||
value := mag / math.Pow(10, exponent)
|
||||
|
||||
// Handle special case where value is exactly 1000.0
|
||||
// Should return 1M instead of 1000k
|
||||
if value == 1000.0 {
|
||||
exponent += 3
|
||||
value = input / math.Pow(10, exponent)
|
||||
value = mag / math.Pow(10, exponent)
|
||||
}
|
||||
|
||||
value = math.Copysign(value, input)
|
||||
|
||||
prefix := siPrefixTable[exponent]
|
||||
return value, prefix
|
||||
}
|
||||
@@ -87,7 +90,7 @@ func ComputeSI(input float64) (float64, string) {
|
||||
// e.g. SI(2.2345e-12, "F") -> 2.2345pF
|
||||
func SI(input float64, unit string) string {
|
||||
value, prefix := ComputeSI(input)
|
||||
return Ftoa(value) + prefix + unit
|
||||
return Ftoa(value) + " " + prefix + unit
|
||||
}
|
||||
|
||||
var errInvalid = errors.New("invalid input")
|
||||
|
||||
Reference in New Issue
Block a user