package stringutils

import "github.com/containers/storage/pkg/stringutils"

Package stringutils provides helper functions for dealing with strings.

Index

Functions

func Ellipsis

func Ellipsis(s string, maxlen int) string

Ellipsis truncates a string to fit within maxlen, and appends ellipsis (...). For maxlen of 3 and lower, no ellipsis is appended.

func GenerateRandomASCIIString

func GenerateRandomASCIIString(n int) string

GenerateRandomASCIIString generates an ASCII random string with length n.

func GenerateRandomAlphaOnlyString

func GenerateRandomAlphaOnlyString(n int) string

GenerateRandomAlphaOnlyString generates an alphabetical random string with length n.

func InSlice

func InSlice(slice []string, s string) bool

InSlice tests whether a string is contained in a slice of strings or not. Comparison is case insensitive

func RemoveFromSlice

func RemoveFromSlice(slice []string, s string) (ret []string)

RemoveFromSlice removes a string from a slice. The string can be present multiple times. The entire slice is iterated.

func ShellQuoteArguments

func ShellQuoteArguments(args []string) string

ShellQuoteArguments takes a list of strings and escapes them so they will be handled right when passed as arguments to a program via a shell

func Truncate

func Truncate(s string, maxlen int) string

Truncate truncates a string to maxlen.

Source Files

stringutils.go

Version
v1.58.0 (latest)
Published
Apr 15, 2025
Platform
linux/amd64
Imports
3 packages
Last checked
3 weeks ago

Tools for package owners.