Documentation
¶
Overview ¶
Package strings provides string utility functions for the muster project. It includes functions for text manipulation, truncation, and formatting that are used across multiple packages.
Index ¶
Constants ¶
const DefaultDescriptionMaxLen = 60
DefaultDescriptionMaxLen is the default maximum length for descriptions in formatted output. This constant is shared across packages to ensure consistent truncation behavior.
const MinTruncateLen = 4
MinTruncateLen is the minimum maxLen value for TruncateDescription. Values smaller than this would not leave room for meaningful content plus "...".
Variables ¶
This section is empty.
Functions ¶
func TruncateDescription ¶
TruncateDescription truncates a string to maxLen characters and ensures single-line output. It replaces newlines with spaces, collapses multiple whitespace characters into single spaces, and adds "..." if truncated.
The function handles Unicode correctly by operating on runes rather than bytes, preventing truncation in the middle of multi-byte characters.
If maxLen is less than MinTruncateLen (4), it is clamped to MinTruncateLen to ensure there is room for at least one character plus "...".
Args:
- s: The string to truncate
- maxLen: Maximum length of the result (including "..." if truncated)
Returns:
- Truncated and sanitized string
Types ¶
This section is empty.