Any program that reports on files, downloads or memory ends up printing a byte
count, and a bare number of bytes is hard to read at a glance while the loop
that turns it into "1.5 MiB" is fiddly enough to be worth writing once. The repo
already prints a duration in a readable form with TimeDiffHuman, so the same
treatment for sizes fits alongside it.
Definition of done: HumanBytes(bytes uint64) string returns a short string
using powers of 1024, with whole bytes below 1024 and one digit after the
decimal point above that. It has a doc comment and table-driven tests covering
zero, a value just below the first threshold, each unit up to exabytes, a value
that would otherwise round up into the next unit, and the largest value a
uint64 can hold.
Model: opus-5
Any program that reports on files, downloads or memory ends up printing a byte
count, and a bare number of bytes is hard to read at a glance while the loop
that turns it into "1.5 MiB" is fiddly enough to be worth writing once. The repo
already prints a duration in a readable form with `TimeDiffHuman`, so the same
treatment for sizes fits alongside it.
Definition of done: `HumanBytes(bytes uint64) string` returns a short string
using powers of 1024, with whole bytes below 1024 and one digit after the
decimal point above that. It has a doc comment and table-driven tests covering
zero, a value just below the first threshold, each unit up to exabytes, a value
that would otherwise round up into the next unit, and the largest value a
uint64 can hold.
Model: opus-5
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Any program that reports on files, downloads or memory ends up printing a byte
count, and a bare number of bytes is hard to read at a glance while the loop
that turns it into "1.5 MiB" is fiddly enough to be worth writing once. The repo
already prints a duration in a readable form with
TimeDiffHuman, so the sametreatment for sizes fits alongside it.
Definition of done:
HumanBytes(bytes uint64) stringreturns a short stringusing powers of 1024, with whole bytes below 1024 and one digit after the
decimal point above that. It has a doc comment and table-driven tests covering
zero, a value just below the first threshold, each unit up to exabytes, a value
that would otherwise round up into the next unit, and the largest value a
uint64 can hold.
Model: opus-5