Skip to content
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

HumanReadable: respect zero value input #46

Merged
merged 2 commits into from Mar 14, 2022
Merged

Conversation

pdorschner
Copy link
Contributor

If a zero value input is parsed by HumanReadable, it should return always "0MB" and not a panic

Copy link
Member

@tbauriedel tbauriedel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@RincewindsHat Second review and merge if ok please

//
func humanReadable(b uint64, units []string, base float64) (float64, string) {
if b == 0 {
return 0, "MB"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for nitpicking, but why not B instead of MB? Small efficiency improvement at not cost and no doubt about rounding errors.

@pdorschner pdorschner merged commit 56d6449 into master Mar 14, 2022
@pdorschner pdorschner deleted the bug/respect_zero_value branch March 14, 2022 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants