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
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.
One of the great things about the Go standard library is how easy it is to create a sophisticated tool using a small amount of code. In this entry, I will explain how to make a variable-length random string generator that can support any Unicode character. You can find the final result on GitHub or… Continue reading Go, create a Unicode random string generator.