Help us shape the future of Go! Take the 2026 Go Developer Survey

strutil

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeduplicateStrings added in v0.1.19

func DeduplicateStrings(input []string, sorted bool) []string

DeduplicateStrings returns a new slice with whitespace-trimmed, empty, and duplicate entries removed from input. When sorted is true the result is sorted in ascending order. The relative order of first-seen entries is preserved when sorted is false.

func Truncate

func Truncate(s string, maxLen int) string

Truncate truncates a string to the specified maximum length. If the string is longer than maxLen, it's truncated and "..." is appended. If maxLen is 0, returns "..." for non-empty strings, empty string for empty strings. If maxLen is negative, the original string is returned.

func TruncateWithSuffix

func TruncateWithSuffix(s string, maxLen int, suffix string) string

TruncateWithSuffix truncates a string to the specified maximum length with a custom suffix. If the string is longer than maxLen, it's truncated and suffix is appended. If maxLen is 0 or negative, the original string is returned.

Types

This section is empty.

Jump to

Keyboard shortcuts

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