stringutil

package
v0.8.13 Latest Latest
Warning

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

Go to latest
Published: May 28, 2024 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnumToStringArray added in v0.7.22

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 added in v0.8.2

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

FilterElementsFromList filters out elements from a given list

func Lower added in v0.7.22

func Lower(e ProtoEnum) string

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

func NamedGroupMatches added in v0.7.20

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 added in v0.7.6

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 added in v0.6.20

func RandomAlphanumeric(n int) string

RandomAlphanumeric returns a random alphanumeric string of length n

func ScrubANSICodes added in v0.8.13

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 added in v0.7.19

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 added in v0.7.22

func Title(e ProtoEnum) string

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

Types

type EnumToStringFunc added in v0.7.22

type EnumToStringFunc func(item ProtoEnum) string

EnumToStringFunc takes an ProtoEnum and returns a string

type ProtoEnum added in v0.7.22

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