Go · Golang

Go byte units and localized formatting


This article will go through creating byte unit methods for both metric and binary prefixes. The two stringers will take a float64 value and round it with a metric unit. Decimal(15000).String() would return 15.0 kBBinary(15000).String() would return 14.6 KiB Unlike many other byte converters, this will also format the number using international digit separators. While… Continue reading Go byte units and localized formatting

Go · Golang

Center text in a terminal with Go.


This guide will show how simple it is to center text in a terminal or a text file using the Go standard and external libraries. We will create two functions, NCenter, which provides for a width parameter, and a Center func that will determine the center placement based on the width of the terminal screen.… Continue reading Center text in a terminal with Go.