Documentation
¶
Index ¶
- func CompileANSIFilter() *regexp.Regexp
- func ConvertToSorted(m map[int]int) []int
- func ConvertToSortedKeys[V any](m map[int]V) []int
- func DisplayWidth(str string) int
- func IsNumOrSpace(r rune) bool
- func IsNumeric(s string) bool
- func MapKeys[K comparable, V any](m map[K]V) []K
- func Max(a, b int) int
- func Min(a, b int) int
- func Or(cond bool, valid, inValid string) string
- func PadCenter(s, pad string, width int) string
- func PadLeft(s, pad string, width int) string
- func PadRight(s, pad string, width int) string
- func SplitCamelCase(src string) (entries []string)
- func Title(name string) string
- func TruncateString(s string, maxWidth int, suffix ...string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompileANSIFilter ¶
CompileANSIFilter constructs and compiles a regex for matching ANSI sequences. It supports both control sequences and operating system commands like hyperlinks.
func ConvertToSorted ¶
ConvertToSorted returns a sorted slice of map values by key order. It is useful for converting maps into ordered table structures.
func ConvertToSortedKeys ¶
ConvertToSortedKeys returns sorted integer keys of a generic map. This helps when iterating over maps in a consistent order.
func DisplayWidth ¶
DisplayWidth calculates the visual width of a string. ANSI escape sequences are stripped before measurement for accuracy.
func IsNumOrSpace ¶
IsNumOrSpace checks if a rune is a digit or space character. It is used for safely replacing characters in formatting logic.
func IsNumeric ¶
IsNumeric returns true if a string represents a valid number. It supports both integers and floating-point values.
func MapKeys ¶
func MapKeys[K comparable, V any](m map[K]V) []K
MapKeys GetMapKeys returns a slice containing all keys from the input map
func Or ¶
Or returns 'valid' if cond is true; otherwise returns 'inValid'. It simplifies ternary-like decisions for string output.
func PadCenter ¶
PadCenter centers the input string within a fixed width using the pad character. If the string is smaller, extra padding is split between left and right.
func PadLeft ¶
PadLeft right-aligns the string within the specified width. The remaining space on the left is filled using the pad string.
func PadRight ¶
PadRight left-aligns the string within the specified width. The remaining space on the right is filled using the pad string.
func SplitCamelCase ¶
SplitCamelCase breaks a camelCase or PascalCase string into word segments. It handles transitions between uppercase and lowercase characters.
Types ¶
This section is empty.