stringutil

package
v1.30.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 4 Imported by: 56

Documentation

Overview

Package stringutil implements string utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAlpha

func IsAlpha(r rune) bool

IsAlpha returns true for [a-zA-Z].

func IsAlphanumeric

func IsAlphanumeric(r rune) bool

IsAlphanumeric returns true for [0-9a-zA-Z].

func IsLowerAlpha

func IsLowerAlpha(r rune) bool

IsLowerAlpha returns true for [a-z].

func IsLowerAlphanumeric

func IsLowerAlphanumeric(r rune) bool

IsLowerAlphanumeric returns true for [0-9a-z].

func IsNumeric

func IsNumeric(r rune) bool

IsNumeric returns true for [0-9].

func IsUpperAlpha

func IsUpperAlpha(r rune) bool

IsUpperAlpha returns true for [A-Z].

func JoinSliceQuoted

func JoinSliceQuoted(s []string, sep string) string

JoinSliceQuoted joins the slice with quotes.

func SliceToHumanString

func SliceToHumanString(s []string) string

SliceToHumanString prints the slice as "e1, e2, and e3".

func SliceToHumanStringOr added in v1.12.0

func SliceToHumanStringOr(s []string) string

SliceToHumanStringOr prints the slice as "e1, e2, or e3".

func SliceToHumanStringOrQuoted added in v1.12.0

func SliceToHumanStringOrQuoted(s []string) string

SliceToHumanStringOrQuoted prints the slice as `"e1", "e2", or "e3"`.

func SliceToHumanStringQuoted

func SliceToHumanStringQuoted(s []string) string

SliceToHumanStringQuoted prints the slice as `"e1", "e2", and "e3"`.

func SliceToString

func SliceToString(s []string) string

SliceToString prints the slice as [e1,e2].

func SliceToUniqueSortedSliceFilterEmptyStrings

func SliceToUniqueSortedSliceFilterEmptyStrings(s []string) []string

SliceToUniqueSortedSliceFilterEmptyStrings returns a sorted copy of s with no duplicates and no empty strings.

Strings with only spaces are considered empty.

func SplitTrimLines

func SplitTrimLines(output string) []string

SplitTrimLines splits the output into individual lines and trims the spaces from each line.

func SplitTrimLinesNoEmpty

func SplitTrimLinesNoEmpty(output string) []string

SplitTrimLinesNoEmpty splits the output into individual lines and trims the spaces from each line.

This removes any empty lines.

func ToLowerSnakeCase

func ToLowerSnakeCase(s string, options ...SnakeCaseOption) string

ToLowerSnakeCase transforms s to lower_snake_case.

func ToPascalCase

func ToPascalCase(s string) string

ToPascalCase converts s to PascalCase.

Splits on '-', '_', ' ', '\t', '\n', '\r'. Uppercase letters will stay uppercase,

func ToUpperSnakeCase

func ToUpperSnakeCase(s string, options ...SnakeCaseOption) string

ToUpperSnakeCase transforms s to UPPER_SNAKE_CASE.

func TrimLines

func TrimLines(output string) string

TrimLines splits the output into individual lines and trims the spaces from each line.

This also trims the start and end spaces from the original output.

Types

type SnakeCaseOption

type SnakeCaseOption func(*snakeCaseOptions)

SnakeCaseOption is an option for snake_case conversions.

func SnakeCaseWithNewWordOnDigits

func SnakeCaseWithNewWordOnDigits() SnakeCaseOption

SnakeCaseWithNewWordOnDigits is a SnakeCaseOption that signifies to split on digits, ie foo_bar_1 instead of foo_bar1.

Jump to

Keyboard shortcuts

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