stringutil

package
v0.8.17 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnumToStringArray

func EnumToStringArray[T ProtoEnum](items []T, f EnumToStringFunc) []string

EnumToStringArray takes an array of enum values and returns an array of their string values after applying EnumToStringFunc on each item.

func FilterElementsFromList

func FilterElementsFromList(l []string, without ...string) []string

FilterElementsFromList filters out elements from a given list.

func Lower

func Lower(e ProtoEnum) string

Lower takes an enum and returns its string value in lower case mode.

func NamedGroupMatches

func NamedGroupMatches(s string, re *regexp.Regexp) (map[string][]string, []string)

NamedGroupMatches returns a map with all found named regex groups as keys and an array of all matches as the value and an array of all the keys in the order they were set in the regex (this is since the map keys order won't be predictable).

func ProcessParamsAndQuotes

func ProcessParamsAndQuotes(args []string) []string

ProcessParamsAndQuotes takes in a slice of strings, and rearranges the slices depending on quotes and parenthesis.

For example "hello ", "wor(", "ld)" becomes "hello ", "wor( ld)".

func RandomAlphanumeric

func RandomAlphanumeric(n int) string

RandomAlphanumeric returns a random alphanumeric string of length n.

func ScrubANSICodes

func ScrubANSICodes(input string) string

ScrubANSICodes removes ANSI escape codes from a string.

func ScrubCredentials

func ScrubCredentials(s string) string

ScrubCredentials removes credentials from a string.

func ScrubCredentialsAll

func ScrubCredentialsAll(s string) string

ScrubCredentialsAll scrubs all credentials from a longer piece of text.

func StrOrDefault

func StrOrDefault(str, defaultStr string) string

StrOrDefault returns str or defaultStr when str is empty.

func Title

func Title(e ProtoEnum) string

Title takes an enum and returns its string value in title mode.

Types

type EnumToStringFunc

type EnumToStringFunc func(item ProtoEnum) string

EnumToStringFunc takes an ProtoEnum and returns a string.

type ProtoEnum

type ProtoEnum interface {
	fmt.Stringer
	Type() protoreflect.EnumType
}

Jump to

Keyboard shortcuts

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