strings

package
v0.0.10-test Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClipLeft added in v0.0.10

func ClipLeft(s string, maxLength int) string

func ClipRight added in v0.0.10

func ClipRight(s string, maxLength int) string

func MaxInt

func MaxInt(a int, b int) int

func MinInt

func MinInt(a int, b int) int

func PrettyPrintMap added in v0.0.10

func PrettyPrintMap[K comparable, V any](m map[K]V) string

Single line map string format from "map[foo:90 bar:30]" to "(foo: 90, bar: 30)"

Types

type SortBy added in v0.0.10

type SortBy struct {
	Name   string
	Number int
	Mode   SortMode
	Order  StrOrder
}

type SortMode added in v0.0.10

type SortMode int

SortMode defines How to sort.

const (
	// Asc sorts the column in Ascending order alphabetically.
	Asc SortMode = iota
	// AscNumeric sorts the column in Ascending order numerically.
	AscNumeric
	// Custom sorts the column in Ascending order by custom string index order
	AscCustom
	// Dsc sorts the column in Descending order alphabetically.
	Dsc
	// DscNumeric sorts the column in Descending order numerically.
	DscNumeric
	// Custom sorts the column in Descending order by custom string index order
	DscCustom
)

type StrOrder added in v0.0.10

type StrOrder []string

StrOrder defines a custom index to sort by. Ex: StrOrder{"Hot", "Warm", "Cold"}

func (StrOrder) Index added in v0.0.10

func (strOrder StrOrder) Index(s string) int

Finds the index of a string in an array

type Table

type Table struct {
	// contains filtered or unexported fields
}

func NewTable

func NewTable(header ...string) *Table

func (*Table) NumRows added in v0.0.10

func (t *Table) NumRows() int

func (Table) Sort added in v0.0.10

func (t Table) Sort() *Table

func (Table) SortBy added in v0.0.10

func (t Table) SortBy(sortBy []SortBy) *Table

SortBy sets the rules for sorting the Rows in the order specified. i.e., the first SortBy instruction takes precedence over the second and so on. Any duplicate instructions on the same column will be discarded while sorting.

func (Table) String

func (t Table) String() string

func (*Table) TotalsByCol added in v0.0.10

func (t *Table) TotalsByCol(col int) map[string]int

func (Table) WithFooter added in v0.0.10

func (t Table) WithFooter(item string) *Table

func (Table) WithHeader

func (t Table) WithHeader(items ...string) *Table

func (Table) WithRow

func (t Table) WithRow(row ...string) *Table

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL