strutil

package
v1.0.22 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Number       = "0123456789"
	Alphabet     = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
	Alphanumeric = Alphabet + Number
)

Variables

This section is empty.

Functions

func Bytes2String added in v1.0.0

func Bytes2String(b []byte) string

Bytes2String more effect but not safe

func Compact added in v1.0.0

func Compact(array []string) []string

Compact remove empty string element.

func Contained added in v1.0.0

func Contained(arr []string, flag string) (b bool)

Contained check any element in arr contained by flag

func Contains added in v1.0.0

func Contains(arr []string, flag string) (b bool)

Contains check any element in arr equal to flag

func ContainsBy added in v1.0.0

func ContainsBy(arr []string, fn func(str string) bool) (b bool)

ContainsBy check any element in arr by fn

func ContainsChineseChar added in v1.0.0

func ContainsChineseChar(str string) bool

ContainsChineseChar check str contains chinese char

func First added in v1.0.0

func First(array []string) string

First return first element of string array.

func HasPrefix added in v1.0.0

func HasPrefix(arr []string, prefix string) (b bool)

HasPrefix check any element in arr has prefix

func HasSuffix added in v1.0.0

func HasSuffix(arr []string, suffix string) (b bool)

HasSuffix check any element in arr has suffix

func Last added in v1.0.0

func Last(array []string) string

Last return last element of string array.

func Nth added in v1.0.0

func Nth(array []string, idx int) string

Nth return the nth element. if index beyond the length, return "".

func RandomAlphabet added in v1.0.0

func RandomAlphabet(n int) string

RandomAlphabet return a random n length string of alphabet.

func RandomAlphanumeric added in v1.0.0

func RandomAlphanumeric(n int) string

RandomAlphanumeric return a random n length string of alphanumeric.

func RandomNumber added in v1.0.0

func RandomNumber(n int) string

RandomNumber return a random n length string of number.

func ShortID added in v1.0.0

func ShortID() string

ShortID generate short id. Use RandomAlphanumeric(10) instead When short id generate fail.

func String2Bytes added in v1.0.0

func String2Bytes(s string) []byte

String2Bytes more effect but not safe

Types

This section is empty.

Jump to

Keyboard shortcuts

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