-
Notifications
You must be signed in to change notification settings - Fork 39
Add HumanSizeWithPrecision
function
#20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add HumanSizeWithPrecision
function
#20
Conversation
// CustomSize returns a human-readable approximation of a size | ||
// using custom format. | ||
func CustomSize(format string, size float64, base float64, _map []string) string { | ||
func customSize(size float64, base float64, _map []string) (float64, string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this could be called calculateSizeAndUnit()
, getSizeAndUnit()
or something like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @dnephin. The PR has been updated to getSizeAndUnit
. Let me know if there are any issues.
This fix adds `HumanSizeWithPrecision` func so that instead of fixed precision of 4 in `HumanSize`, any precision could be specified. This fix is related to 26303, 26300 in docker. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
LGTM |
LGTM 🐸 |
relevant changes: - docker/go-units#8 Enhance FromHumanSize to parse float64 string - docker/go-units#20 Add `HumanSizeWithPrecision` function Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
relevant changes: - docker/go-units#8 Enhance FromHumanSize to parse float64 string - docker/go-units#20 Add `HumanSizeWithPrecision` function Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
relevant changes: - docker/go-units#8 Enhance FromHumanSize to parse float64 string - docker/go-units#20 Add `HumanSizeWithPrecision` function Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
relevant changes: - docker/go-units#8 Enhance FromHumanSize to parse float64 string - docker/go-units#20 Add `HumanSizeWithPrecision` function Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
relevant changes: - docker/go-units#8 Enhance FromHumanSize to parse float64 string - docker/go-units#20 Add `HumanSizeWithPrecision` function Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
relevant changes: - docker/go-units#19 make 1 second not to be plural seconds - docker/go-units#20 Add `HumanSizeWithPrecision` function - docker/go-units#21 change week display rule - docker/go-units#22 Better human duration precision - docker/go-units#23 Removes spaces before unit - docker/go-units#27 Fix containerd#26 - RAMInBytes Bug - docker/go-units#33 Fix handling of unlimited (-1) ulimit values - docker/go-units#34 Revert 46 minute threshold Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
relevant changes: - docker/go-units#8 Enhance FromHumanSize to parse float64 string - docker/go-units#20 Add `HumanSizeWithPrecision` function Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
relevant changes: - docker/go-units#8 Enhance FromHumanSize to parse float64 string - docker/go-units#20 Add `HumanSizeWithPrecision` function Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
relevant changes: - docker/go-units#8 Enhance FromHumanSize to parse float64 string - docker/go-units#20 Add `HumanSizeWithPrecision` function Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
relevant changes: - docker/go-units#8 Enhance FromHumanSize to parse float64 string - docker/go-units#20 Add `HumanSizeWithPrecision` function Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
relevant changes: - docker/go-units#8 Enhance FromHumanSize to parse float64 string - docker/go-units#20 Add `HumanSizeWithPrecision` function Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
relevant changes: - docker/go-units#8 Enhance FromHumanSize to parse float64 string - docker/go-units#20 Add `HumanSizeWithPrecision` function Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This fix adds
HumanSizeWithPrecision
func so that instead of fixedprecision of 4 in
HumanSize
, any precision could be specified.This fix is related to:
moby/moby#26303
moby/moby#26300
in docker.
Signed-off-by: Yong Tang yong.tang.github@outlook.com