Documentation
¶
Index ¶
- func AddSlashes(str string) string
- func AddSlashesCustom(str string, escapeChars string) string
- func After(str, needle string) string
- func AfterLast(str, needle string) string
- func Append(values ...string) string
- func Base32ExtendedDecode(data []byte) (text []byte, err error)
- func Base32ExtendedEncode(data []byte) (text []byte, err error)
- func Base64Decode(text []byte) (data []byte, err error)
- func Base64Encode(data []byte) (text []byte, err error)
- func BcryptHashCompare(str string, hash string) bool
- func Before(str, needle string) string
- func BeforeLast(str, needle string) string
- func Between(str string, startNeedle string, endNeedle string) (result string, found bool)
- func CharAt(str string, index int) string
- func ContainsAnyChar(str string, charset string) bool
- func ContainsOnly(str string, charset string) bool
- func IntToBase32(num int) string
- func IntToBase36(num int) string
- func Is(str string, patterns ...string) bool
- func IsAscii(str string) bool
- func IsEmpty(str string) bool
- func IsMap(str string) bool
- func IsMatch(str string, patterns ...string) bool
- func IsNotEmpty(str string) bool
- func IsSlice(str string) bool
- func IsUlid(str string) bool
- func IsUuid(str string) bool
- func LeftFrom(str, needle string) string
- func LeftPad(s string, padStr string, overallLen int) string
- func MD5(text string) string
- func Random(length int) string
- func RandomFromGamma(length int, gamma string) string
- func RemovePrefix(str string, prefix string) string
- func RemoveSuffix(str string, suffix string) string
- func RightFrom(str, needle string) string
- func RightPad(s string, padStr string, overallLen int) string
- func Slugify(s string, replaceWith rune) string
- func Substr(str string, start int, length ...int) string
- func ToBcryptHash(str string) (string, error)
- func ToBytes(s string) []byte
- func ToCamel(in string) string
- func ToSnake(in string) string
- func Truncate(str string, length int, ellipsis string) string
- func UcFirst(str string) string
- func UcSplit(s string) []string
- func Upper(str string) string
- func WordCount(str string) int
- func Words(str string, limit int, end ...string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddSlashes ¶ added in v0.8.0
AddSlashes returns a string with backslashes added before characters that need to be escaped.
These characters are: single quote (') double quote (") backslash (\)
func AddSlashesCustom ¶ added in v0.8.0
AddSlashesCustom returns a string with backslashes added before characters specified in the escapeChars string.
func After ¶ added in v0.7.0
After returns the substring after the first occurrence of the specified needle.
func AfterLast ¶ added in v0.7.0
AfterLast returns the substring after the last occurrence of the specified needle.
func Base32ExtendedDecode ¶ added in v0.7.0
Base32ExtendedDecode encodes binary data to base32 extended (RFC 4648) encoded text.
func Base32ExtendedEncode ¶ added in v0.7.0
Base32ExtendedEncode encodes binary data to base32 extended (RFC 4648) encoded text.
func Base64Decode ¶ added in v0.7.0
Base64Decode decodes base64 text to binary data.
func Base64Encode ¶ added in v0.7.0
Base64Encode encodes binary data to base64 encoded text.
func BcryptHashCompare ¶ added in v0.7.0
BcryptHashCompare compares the string to a bcrypt hash
func Before ¶ added in v0.7.0
Before returns the substring before the first occurrence of the specified search string.
func BeforeLast ¶ added in v0.7.0
BeforeLast returns the substring before the last occurrence of the specified search string.
func CharAt ¶ added in v0.7.0
CharAt returns the character at the specified index.
If the specified index is negative, it is counted from the end of the string.
Business logic: 1. Convert the string to a rune slice for proper handling of UTF-8 encoding. 2. Get the length of the rune slice. 3. Handle negative indices by converting them to positive indices (e.g. -1 -> length - 1). 4. Check if the index is out of bounds. 5. If the index is out of bounds, return an empty string. 6. Return the character at the specified index.
Example:
str.CharAt("Hello World", 0) // Returns "H" str.CharAt("Hello World", -1) // Returns "d" str.CharAt("Hello World", 20) // Returns ""
Parameters: - str: The string to get the character from. - index: The index of the character to get.
Returns: - The character at the specified index.
func ContainsAnyChar ¶ added in v0.7.0
ContainsAnyChar returns true if the string contains any of the characters in the provided charset
func ContainsOnly ¶ added in v0.7.0
ContainsOnly returns true is the string contains only charcters from the specified charset
func IntToBase32 ¶ added in v0.7.0
func IntToBase36 ¶ added in v0.7.0
func IsMatch ¶ added in v0.7.0
IsMatch returns true if the string matches any of the given patterns.
func IsNotEmpty ¶ added in v0.7.0
IsNotEmpty returns true if the string is not empty.
func RandomFromGamma ¶ added in v0.7.0
RandomFromGamma generates random string of specified length with the characters specified in the gamma string
func RemovePrefix ¶ added in v0.7.0
func RemoveSuffix ¶ added in v0.7.0
func Slugify ¶ added in v0.7.0
StrSlugify replaces each run of characters which are not ASCII letters or numbers with the Replacement character, except for leading or trailing runs. Letters will be stripped of diacritical marks and lowercased. Letter or number codepoints that do not have combining marks or a lower-cased variant will be passed through unaltered.
func Substr ¶ added in v0.7.0
Substr returns a substring of a given string, starting at the specified index and with a specified length. It handles UTF-8 encoded strings.
func ToBcryptHash ¶ added in v0.7.0
ToBcryptHash converts the string to bcrypt hash
func ToSnake ¶ added in v0.7.0
ToSnake convert the given string to snake case following the Golang format: acronyms are converted to lower-case and preceded by an underscore.
func Truncate ¶ added in v0.7.0
Truncate truncates a string to a given length, adding an ellipsis if necessary.
func UcSplit ¶ added in v0.8.0
UcSplit splits the string into words using uppercase characters as the delimiter.
func Words ¶ added in v0.8.0
Words returns the string truncated to the given number of words. If limit is less than 1, it returns an empty string. If limit is greater than or equal to the number of words, it returns the full string. An optional end string can be provided to customize the truncation suffix.
Types ¶
This section is empty.
Source Files
¶
- add_slashes.go
- after.go
- after_last.go
- append.go
- base32_extended_decode.go
- base32_extended_encode.go
- base64_decode.go
- base64_encode.go
- bcrypt_hash_compare.go
- before.go
- before_last.go
- between.go
- char_at.go
- contains_any_char.go
- contains_only.go
- functions.go
- int_to_base32.go
- int_to_base36.go
- is.go
- is_match.go
- isascii.go
- isempty.go
- ismap.go
- isnotempty.go
- isslice.go
- isulid.go
- isuuid.go
- left_from.go
- left_pad.go
- md5.go
- random.go
- random_from_gamma.go
- remove_prefix.go
- remove_suffix.go
- right_from.go
- right_pad.go
- slugify.go
- str.go
- substr.go
- to_bcrypt_hash.go
- to_bytes.go
- to_camel.go
- to_snake.go
- truncate.go
- uc_first.go
- uc_split.go
- upper.go
- word_count.go
- words.go