strings

package
v0.1.231 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: Apache-2.0 Imports: 1 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
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

func TruncateDescription(s string, maxLen int) string

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.

Jump to

Keyboard shortcuts

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