Documentation ¶
Index ¶
- func InSlice(slice []string, s string) bool
- func Is(pattern, value string) bool
- func IsUUID(str string) bool
- func Len(s string) int
- func MD5(s string) string
- func Random(length int) string
- func Replace(s, from, to string) string
- func Reverse(s string) string
- func SHA1(s string) string
- func Shuffle(s string) string
- func UUID() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InSlice ¶ added in v2.10.0
InSlice checks if a string is in a string slice.
Example:
InSlice([]string{"1", "2"}, "1") // true
func Is ¶
Is returns true if the value matches the pattern. The pattern can contain the wildcard character *.
Example:
Is("*.example.com", "www.example.com") // true Is("*.example.com", "example.com") // false
func Len ¶
Len returns the length of a string. Support chinese characters.
Example:
Len("abc") // 3 Len("张三李四") // 4
func MD5 ¶ added in v2.13.0
MD5 returns the md5 hash of a string.
Example:
MD5("abc") // 900150983cd24fb0d6963f7d28e17f72
func Random ¶
Random returns a random string with the specified length.
Example:
Random(10) // "qujrlkhyqr"
func Replace ¶
Replace replaces all occurrences of one substring with another.
Example:
Replace("aabbcc", "a", "b") // "bbbbcc"
func Reverse ¶
Reverse returns a string with its characters in reverse order.
Example:
Reverse("abc") // "cba"
func SHA1 ¶ added in v2.13.0
SHA1 returns the sha1 hash of a string.
Example:
SHA1("abc") // a9993e364706816aba3e25717850c26c9cd0d89d
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.