Documentation ¶
Overview ¶
Package text provides utilities for formatting text data.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatBits ¶
FormatBitsWithLowPrecision takes in a bit (not byte) count and returns a formatted string including units with no decimal places
e.g. 12g, 0b, 124k
func FormatByteAmount ¶
FormatByteAmount takes an int64 representing a size in bytes and returns a formatted string of a minimum amount of significant figures.
e.g. 12.4 GB, 0.0 B, 124.5 KB
func FormatMegabyteAmount ¶
FormatMegabyteAmount is equivalent to FormatByteAmount but expects an amount of MB instead of bytes.
Types ¶
type GridWriter ¶
type GridWriter struct { ColumnPadding int MinWidth int Grid [][]Cell CurrentRow int // contains filtered or unexported fields }
func (*GridWriter) EndRow ¶
func (gw *GridWriter) EndRow()
EndRow terminates the row of cells and begins a new row in the grid.
func (*GridWriter) Feed ¶
func (gw *GridWriter) Feed(data string)
Feed writes the given string into the current cell but allowing the cell contents to extend past the width of the current column, and ends the row.
func (*GridWriter) Flush ¶
func (gw *GridWriter) Flush(w io.Writer)
Flush writes the fully-formatted grid to the given io.Writer.
func (*GridWriter) FlushRows ¶
func (gw *GridWriter) FlushRows(w io.Writer)
FlushRows writes the fully-formatted grid to the given io.Writer, but gives each row its own Write() call instead of using newlines.
func (*GridWriter) Reset ¶
func (gw *GridWriter) Reset()
Reset discards any grid data and resets the current row.
func (*GridWriter) WriteCell ¶
func (gw *GridWriter) WriteCell(data string)
WriteCell writes the given string into the next cell in the current row.
func (*GridWriter) WriteCells ¶
func (gw *GridWriter) WriteCells(data ...string)
WriteCells writes multiple cells by calling WriteCell for each argument.