I was profiling my application some time ago, by logging memory usage. Instead of “1073741824 bytes”, I want to log it as “1M”. This is more readable. Then I came across this wonderful package that format byte size (unsigned integer) into a more readable text.
Example:
bytefmt.ByteSize(uint64(1024)) // returns "1K"