Computing Magazine

Human Readable Byte Formatter For Go

Posted on the 01 February 2016 by Hean Hong Leong @hongster
Human Readable Byte Formatter For Go:

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"


Back to Featured Articles on Logo Paperblog