Documentation
¶
Index ¶
- Constants
- func Clusters(input string) iter.Seq[string]
- func CutMultiline(s string, left, right int) string
- func Duration(d time.Duration, rel int) string
- func IsFlatValue[T comparable](data map[T]any) bool
- func MaskValue(v any) any
- func PadMinimum(s string, minWidth int) string
- func Time(t time.Time) string
- func TimeRelative(t time.Time, postfix bool) string
- func ToJSON(data any, mask bool, indent int) string
- func ToYAML(data any, mask bool, indent int) string
- func Trunc(s string, length int) string
- func TruncLeft(s string, length int) string
- func TruncLeftMultiline(s string, length int) string
- func TruncMaybePath(s string, length int) string
- func TruncMultiline(s string, length int) string
- func TruncPath(s string, length int) string
- func TruncReset(s string) string
Constants ¶
const ANSIReset = "\x1b[m"
const MaskReplacementValue = "***"
const TruncateEllipsis = "…" // Should be 1 character wide.
Variables ¶
This section is empty.
Functions ¶
func CutMultiline ¶
func Duration ¶
Duration formats a duration, and optionally adds a relative prefix/suffix. If rel is 0, then the duration is formatted without a relative prefix/suffix. If rel is 1, it is considered in the future. If rel is -1, it is considered in the past.
func IsFlatValue ¶
func IsFlatValue[T comparable](data map[T]any) bool
IsFlatValue returns true when the map values provided is a flat value (can be rendered into a 1 dimensional list).
func PadMinimum ¶
PadMinimum pads a string to a minimum width, adding even padding on both sides of the string if the string is shorter than the minimum width.
func TimeRelative ¶
TimeRelative formats a time.Time as a relative string (e.g. "in 10 seconds", "10 seconds ago", "now", "n/a" for zero value).
func ToJSON ¶
ToJSON will convert the provided data value into JSON. If mask is true, all concrete values will be masked with asterisks.
func ToYAML ¶
ToYAML will convert the provided data value into a YAML string, optionally masking the values if the mask flag is true.
func Trunc ¶
Trunc truncates a string to a given length, adding a tail to the end if the string is longer than the given length. This function is aware of ANSI escape codes and will not break them, and accounts for wide-characters (such as East-Asian characters and emojis). This treats the text as a sequence of graphemes.
func TruncLeftMultiline ¶
func TruncMaybePath ¶
TruncMaybePath truncates a string similar to Trunc, but if one of the parts of the string looks like a path, it will be truncated using TruncPath.
func TruncMultiline ¶
TruncMultiline is similar to Trunc, but it truncates each line of a multiline string separately.
func TruncPath ¶
TruncPath dynamically truncates a path to a given length, prioritizing keeping both start and end segments when possible.
func TruncReset ¶
TruncReset removes the ANSI reset sequence from a string.
Types ¶
This section is empty.