xstring

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2021 License: MIT Imports: 7 Imported by: 6

README

xstring

References
  • xtesting*
Functions
  • func Capitalize(s string) string
  • func Uncapitalize(s string) string
  • func CapitalizeAll(s string) string
  • func UncapitalizeAll(s string) string
  • func RemoveBlanks(s string) string
  • func PascalCase(s string, seps ...string) string
  • func CamelCase(s string, seps ...string) string
  • func SnakeCase(s string, seps ...string) string
  • func KebabCase(s string, seps ...string) string
  • func TimeUUID(t time.Time, count int) string
  • func RandString(count int, runes []rune) string
  • func RandCapitalLetterString(count int) string
  • func RandLowercaseLetterString(count int) string
  • func RandLetterString(count int) string
  • func RandNumberString(count int) string
  • func RandCapitalLetterNumberString(count int) string
  • func RandLowercaseLetterNumberString(count int) string
  • func DefaultMaskToken(token string) string
  • func MaskToken(token string) string
  • func FastStob(s string) []byte
  • func FastBtos(bs []byte) string
  • func EncodeUrlValues(values map[string][]string, escapeFunc func(string) string) string
  • func PadLeft(s string, paddingChar rune, totalLength int) string
  • func PadRight(s string, paddingChar rune, totalLength int) string
  • func GetLeft(s string, length int) string
  • func GetRight(s string, length int) string
  • func SplitAndGet(s string, sep string, index int) string

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CamelCase added in v1.5.0

func CamelCase(s string, seps ...string) string

CamelCase rewrites string in camel case using word separator. By default "_", "-". ".", " ", " " are treated as word separator.

func Capitalize

func Capitalize(s string) string

Capitalize capitalizes the first letter of the whole string, this will ignore all trailing spaces.

func CapitalizeAll added in v1.5.0

func CapitalizeAll(s string) string

CapitalizeAll capitalizes all the first letter in words of the whole string, this will trim the trailing space.

func DefaultMaskToken added in v1.5.0

func DefaultMaskToken(s string) string

DefaultMaskToken masks and returns a token string. Here the masked result only shows the first and last two characters at most, and the length of characters shown is restrict less than masked.

func EncodeUrlValues added in v1.5.0

func EncodeUrlValues(values map[string][]string, escapeFunc func(string) string) string

EncodeUrlValues encodes the values (see url.Values) into url encoded form ("bar=baz&foo=quux") sorted by key with escape. The escapeFunc can be url.QueryEscape, url.PathEscape or the functions you defined, use nil for no escape.

func FastBtos added in v1.5.0

func FastBtos(bs []byte) string

FastBtos fast casts []byte to string in an unsafe ways.

func FastStob added in v1.5.0

func FastStob(s string) []byte

FastStob fast casts string to []byte in an unsafe ways.

func GetLeft added in v1.4.4

func GetLeft(s string, length int) string

GetLeft gets the left part of the string with length.

func GetRight added in v1.4.4

func GetRight(s string, length int) string

GetRight gets the right part of the string with length.

func KebabCase added in v1.5.0

func KebabCase(s string, seps ...string) string

KebabCase rewrites string in kebab case using word separator. By default "_", "-". ".", " ", " " are treated as word separator.

func MaskToken

func MaskToken(s string, mask rune, indices ...int) string

MaskToken masks and returns a token string with given mask run and indices array, which support minus index.

func PadLeft added in v1.4.4

func PadLeft(s string, char rune, totalLength int) string

PadLeft returns the string with length of totalLength, which is padded by char in left.

func PadRight added in v1.4.4

func PadRight(s string, char rune, totalLength int) string

PadRight returns the string with length of totalLength, which is padded by char in right.

func PascalCase added in v1.5.0

func PascalCase(s string, seps ...string) string

PascalCase rewrites string in pascal case using word separator. By default "_", "-". ".", " ", " " are treated as word separator.

func RandCapitalLetterNumberString added in v1.5.0

func RandCapitalLetterNumberString(count int) string

RandCapitalLetterNumberString generates a random string combined by capital letters and numbers, that is ABCDEFGHIJKLMNOPQRSTUVWXYZ + 0123456789.

func RandCapitalLetterString added in v1.5.0

func RandCapitalLetterString(count int) string

RandCapitalLetterString generates a random string combined by capital letters, that is ABCDEFGHIJKLMNOPQRSTUVWXYZ.

func RandLetterString

func RandLetterString(count int) string

RandLetterString generates a random string combined by allcase letters, that is ABCDEFGHIJKLMNOPQRSTUVWXYZ + abcdefghijklmnopqrstuvwxyz.

func RandLowercaseLetterNumberString added in v1.5.0

func RandLowercaseLetterNumberString(count int) string

RandLowercaseLetterNumberString generates a random string combined by lowercase letters and numbers, that is abcdefghijklmnopqrstuvwxyz + 0123456789.

func RandLowercaseLetterString added in v1.5.0

func RandLowercaseLetterString(count int) string

RandLowercaseLetterString generates a random string combined by lowercase letters, that is abcdefghijklmnopqrstuvwxyz.

func RandNumberString

func RandNumberString(count int) string

RandNumberString generates a random string combined by numbers, that is 0123456789.

func RandString

func RandString(count int, runes []rune) string

RandString generates a string by given rune slice in random order.

func RemoveBlanks added in v1.5.0

func RemoveBlanks(s string) string

RemoveBlanks replaces all blanks (\s and a wide space) to a single space. About blank, see unicode.IsSpace.

func SnakeCase added in v1.5.0

func SnakeCase(s string, seps ...string) string

SnakeCase rewrites string in snake case using word separator. By default "_", "-". ".", " ", " " are treated as word separator.

func SplitAndGet added in v1.5.0

func SplitAndGet(s string, sep string, index int) string

SplitAndGet returns the string item from the split result slices, this also supports minus index.

func TimeUUID added in v1.5.0

func TimeUUID(t time.Time, count int) string

TimeUUID creates a uuid from given time. If the count is larger than 23, the remaining bits will be filled by rand numbers.

func Uncapitalize

func Uncapitalize(s string) string

Uncapitalize uncapitalizes the first letter of the whole string, this will ignore all trailing spaces.

func UncapitalizeAll added in v1.5.0

func UncapitalizeAll(s string) string

UncapitalizeAll uncapitalizes all the first letter in words of the whole string, this will trim the trailing space.

Types

This section is empty.

Jump to

Keyboard shortcuts

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