Strings

package
v0.3.22 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2024 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AndString

func AndString(vals ...string) string

AndString concatenates a list of strings using commas and the word "and" before the last string.

Parameters:

  • vals: The list of strings to concatenate.

Returns:

  • string: The concatenated string.

func ArrayFormatter added in v0.3.8

func ArrayFormatter(values []string) string

ArrayFormatter formats a list of strings as an array.

Parameters:

  • values: The list of strings to format.

Returns:

  • string: The formatted array.

func DateStringer

func DateStringer(date time.Time) string

DateStringer prints the date in the format "1st January, 2006".

Parameters:

  • date: The date to print.

Returns:

  • string: The date in the format "1st January, 2006".

func LongestLine added in v0.3.18

func LongestLine[T any](table [][]T) int

LongestLine finds the longest line in a table.

Parameters:

  • table: The table to find the longest line in.

Returns:

  • int: The length of the longest line. -1 if the table is empty.

func OrString

func OrString(vals ...string) string

OrString concatenates a list of strings using commas and the word "or" before the last string.

Parameters:

  • vals: The list of strings to concatenate.

Returns:

  • string: The concatenated string.

func StringsJoiner added in v0.2.36

func StringsJoiner[T fmt.Stringer](values []T, sep string) string

StringsJoiner joins a list of fmt.Stringer values using a separator.

Parameters:

  • values: The list of fmt.Stringer values to join.
  • sep: The separator to use when joining the strings.

Returns:

  • string: The string representation of the values.

func TabAlign added in v0.3.18

func TabAlign(table [][]string, column int, tabSize int) ([][]string, error)

TabAlign aligns the tabs of a table's column.

Parameters:

  • table: The table to align.
  • column: The column to align.
  • tabSize: The size of the tab.

Returns:

  • [][]string: The aligned table.
  • error: An error of type *errors.ErrInvalidParameter if the tabSize is less than 1 or the column is less than 0.

Behaviors:

  • If the column is not found in the table, the table is returned as is.

func TableEntriesAlign added in v0.3.18

func TableEntriesAlign(table [][]string, tabSize int) ([][]string, error)

TableEntriesAlign aligns the entries of a table.

Parameters:

  • table: The table to align.
  • tabSize: The size of the tab.

Returns:

  • [][]string: The aligned table.
  • error: An error if there was an issue aligning the table.

Errors:

  • *errors.ErrAt: If there was an issue aligning a specific column.
  • *errors.ErrInvalidParameter: If the tabSize is less than 1.

func TimeStringer

func TimeStringer(time time.Time) string

TimeStringer prints the time in the format "3:04 PM".

Parameters:

  • time: The time to print.

Returns:

  • string: The time in the format "3:04 PM".

Types

This section is empty.

Jump to

Keyboard shortcuts

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