Documentation ¶
Overview ¶
The colfmt package supplies various implementations of the col.Formatter interface.
Index ¶
Constants ¶
const DfltTimeFormat = "2006/01/02 15:04:05.000"
DfltTimeFormat is the format that will be used by the Time Formatter for printing out times if no other format is given. Note that the order of the date is Year/Month/Day not Year/Day/Month
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Float ¶
type Float struct { // W gives the minimum space to be taken by the formatted value W int // Prec gives the precision with which to print the value when formatted // Negative values are treated as zero Prec int // IgnoreNil, if set to true will make nil values print as the empty string IgnoreNil bool // Zeroes records any desired special handling for zero values Zeroes *FloatZeroHandler }
Float records the values needed for the formatting of a float(64/32) value
func (Float) Just ¶
func (f Float) Just() col.Justification
Just returns the justification of the value
type FloatZeroHandler ¶
type FloatZeroHandler struct { // Handle, if set to true will check if the value to be printed is zero // (or closer than the given precision can reveal) and if so it will // print the Replacement string instead. The string printed will not be // wider than the minimum space indicated by the given width Handle bool // Replace is the value to be printed for zero if Handle is true Replace string // contains filtered or unexported fields }
FloatZeroHandler is a mixin for handling zero values for columns taking floats
func (*FloatZeroHandler) GetZeroStr ¶
func (z *FloatZeroHandler) GetZeroStr(prec int, v interface{}) (bool, string)
GetZeroStr calculates the appropriate zero string and returns it with a boolean indicating whether it should be used or not (if the value passed was actually zero)
type Int ¶
type Int struct { // W gives the minimum space to be taken by the formatted value W int // IgnoreNil, if set to true will make nil values print as the empty string IgnoreNil bool // HandleZeroes, if set to true will check if the value to be printed is // zero and if so it will print the ZeroReplacement string instead. The // string printed will not be wider than the minimum space given by the W // value HandleZeroes bool // ZeroReplacement is the value to be printed for zero if HandleZeroes is // true ZeroReplacement string }
Int records the values needed for the formatting of an int value
type Percent ¶
type Percent struct { // W gives the minimum space to be taken by the formatted value W int // Prec gives the precision with which to print the value when formatted // Negative values are treated as zero Prec int // IgnoreNil, if set to true will make nil values print as the empty string IgnoreNil bool // SuppressPct, if set to true will cause the '%' sign not to be printed SuppressPct bool // Zeroes records any desired special handling for zero values Zeroes *FloatZeroHandler }
Percent records the values needed for the formatting of a proportion as a percentage value. The value is expected to be a proportion and so is multiplied by 100 to convert it into a percentage value and then a % sign is added to the end (unless SuppressPct is set to true)
func (Percent) Just ¶
func (f Percent) Just() col.Justification
Just returns the justification of the value
type String ¶
type String struct { // W gives the minimum width of the string that should be printed W int // MaxW gives the maximum width of the string, if it is set to zero then // no limit is applied. If it is set to a negative value then the W // value is used. If it is a positive value then that is used MaxW int // StrJust gives the justification to be used StrJust col.Justification // IgnoreNil, if set to true will make nil values print as the empty string IgnoreNil bool }
String records the values needed for the formatting of a string value.
func (String) Just ¶
func (f String) Just() col.Justification
Just returns the justification of the value
type Time ¶
Time records the values needed for the formatting of a time value
func (*Time) Formatted ¶
Formatted returns the value formatted as a time. If the format string is not set then it is set to the DfltTimeFormat.
func (Time) Just ¶
func (f Time) Just() col.Justification
Just returns the justification of the value