Documentation
¶
Index ¶
- Variables
- func MapSortedByKey[Map ~map[K]V, K cmp.Ordered, V any](m Map) iter.Seq2[K, V]
- func SliceAppendIf[T any](slice []T, cond bool, values ...T) []T
- func SliceAppendIfFunc[T any](slice []T, cond bool, f func() []T) []T
- func SlicePrepend[T any](slice []T, elems ...T) []T
- func SlicePrependIf[T any](slice []T, cond bool, values ...T) []T
- func SlicePrependIfFunc[T any](slice []T, cond bool, f func() []T) []T
- func StringContainsAny(s string, substrings ...string) bool
- func Ternary[T any](cond bool, vtrue, vfalse T) T
- func TernaryFunc[T any](cond bool, vtrue, vfalse func() T) T
- func TernaryFuncErr[T any](cond bool, vtrue, vfalse func() (T, error)) (T, error)
- type TablePrinter
- type TablePrinterAlignment
- type TablePrinterColumn
- type TablePrinterOptions
- type TablePrinterRow
- type TablePrinterStyle
Constants ¶
This section is empty.
Variables ¶
var TablePrinterStyleAscii = &TablePrinterStyle{
TopLeft: "+",
TopRight: "+",
TopIntersection: "+",
TopSpacer: "-",
MiddleLeft: "|",
MiddleRight: "|",
MiddleIntersection: "|",
SeparatorLeft: "+",
SeparatorRight: "+",
SeparatorIntersection: "+",
SeparatorSpacer: "-",
BottomLeft: "+",
BottomRight: "+╯",
BottomIntersection: "+",
BottomSpacer: "-",
}
var TablePrinterStyleDefault = &TablePrinterStyle{
TopLeft: "┌",
TopRight: "┐",
TopIntersection: "┬",
TopSpacer: "─",
MiddleLeft: "│",
MiddleRight: "│",
MiddleIntersection: "│",
SeparatorLeft: "├",
SeparatorRight: "┤",
SeparatorIntersection: "┼",
SeparatorSpacer: "─",
BottomLeft: "└",
BottomRight: "┘",
BottomIntersection: "┴",
BottomSpacer: "─",
}
var TablePrinterStyleRounded = &TablePrinterStyle{
TopLeft: "╭",
TopRight: "╮",
TopIntersection: "┬",
TopSpacer: "─",
MiddleLeft: "│",
MiddleRight: "│",
MiddleIntersection: "│",
SeparatorLeft: "├",
SeparatorRight: "┤",
SeparatorIntersection: "┼",
SeparatorSpacer: "─",
BottomLeft: "╰",
BottomRight: "╯",
BottomIntersection: "┴",
BottomSpacer: "─",
}
Functions ¶
func MapSortedByKey ¶
Returns an iterator for the given map that yields the key-value pairs in sorted order.
func SliceAppendIf ¶
Appends the given values to a slice if the condition is fulfilled.
func SliceAppendIfFunc ¶
Appends the given value if the condition is fulfilled. The value is lazily evaluated.
func SlicePrepend ¶
func SlicePrepend[T any](slice []T, elems ...T) []T
Prepends the given elements to the given array.
func SlicePrependIf ¶
Prepends the given values to a slice if the condition is fulfilled.
func SlicePrependIfFunc ¶
Prepends the given value if the condition is fulfilled. The value is lazily evaluated.
func StringContainsAny ¶
Checks if the string contains at least one of the substrings.
func Ternary ¶
A simple ternary function that returns one of two values based on a boolean condition.
func TernaryFunc ¶
Like Ternary but uses functions to lazily evaluate the values.
Types ¶
type TablePrinter ¶
type TablePrinter struct { Options *TablePrinterOptions Columns []*TablePrinterColumn Rows []*TablePrinterRow }
func NewTablePrinter ¶
func NewTablePrinter(options *TablePrinterOptions) *TablePrinter
Create a new TablePrinter with the given options or default options.
func (*TablePrinter) AddRows ¶
func (tp *TablePrinter) AddRows(valueRows ...[]any)
Add rows to the TablePrinter with the given values.
func (*TablePrinter) Print ¶
func (tp *TablePrinter) Print(writer io.Writer)
Print the table to the given writer.
func (*TablePrinter) PrintToFile ¶
func (tp *TablePrinter) PrintToFile(filePath string) error
Print the table to a file.
func (*TablePrinter) SetHeaders ¶
func (tp *TablePrinter) SetHeaders(headers ...string)
Set the headers for the TablePrinter.
type TablePrinterAlignment ¶
type TablePrinterAlignment int
const ( TABLE_PRINTER_ALIGNMENT_LEFT TablePrinterAlignment = iota TABLE_PRINTER_ALIGNMENT_RIGHT )
type TablePrinterColumn ¶
type TablePrinterColumn struct { Header string HeaderAlignment TablePrinterAlignment ValueAlignment TablePrinterAlignment Hide bool // contains filtered or unexported fields }
type TablePrinterOptions ¶
type TablePrinterOptions struct { Padding int Style *TablePrinterStyle }
type TablePrinterRow ¶
type TablePrinterRow struct {
Values []string
}
type TablePrinterStyle ¶
type TablePrinterStyle struct { TopLeft string TopRight string TopIntersection string TopSpacer string MiddleLeft string MiddleRight string MiddleIntersection string SeparatorLeft string SeparatorRight string SeparatorIntersection string SeparatorSpacer string BottomLeft string BottomRight string BottomIntersection string BottomSpacer string }