Documentation ¶
Index ¶
- func CamelCase(s string) string
- func Capitalize(s string) string
- func EndsWith(str, target string, position ...int) (bool, error)
- func Escape(s string) string
- func KebabCase(s string) (string, error)
- func LowerCase(s string) (string, error)
- func LowerFirst(s string) string
- func Pad(s string, length int, char ...string) string
- func PadEnd(s string, length int, char ...string) string
- func PadStart(s string, length int, char ...string) string
- func ParseInt(s string) (int, error)
- func Repeat(s string, times int) string
- func Replace(s, pattern, replacement string) string
- func SnakeCase(s string) string
- func Split(s, separator string, limit int) []string
- func StartsWith(str, target string, position ...int) (bool, error)
- func Unescape(s string) string
- func UpperCase(s string) (string, error)
- func UpperFirst(s string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CamelCase ¶
CamelCase converts a string to CamelCase format. It capitalizes the first letter of each word (except the first word), removes spaces and punctuation, and lower cases the rest of the letters.
func Capitalize ¶
Capitalize the first letter of a string and leaves the rest unchanged.
func EndsWith ¶
EndsWith checks if the string 'str' ends with the target string 'target' optionally up to a specified 'position' in 'str'. It returns true if 'str' ends with 'target', and false otherwise. If 'position' is provided, only the characters up to that position in 'str' are considered.
func Escape ¶
Escape converts special characters in a string to their corresponding HTML entities. It returns the escaped string where special characters are replaced by their entities.
func KebabCase ¶
KebabCase converts a string to kebab-case format, where words are separated by hyphens. It removes spaces, punctuation, and converts letters to lowercase. Returns the kebab-case string and an error if the input string is empty.
func LowerCase ¶
LowerCase converts a string to kebab-case format, where words are separated by hyphens. It removes spaces, punctuation, and converts letters to lowercase. Returns the kebab-case string and an error if the input string is empty.
func LowerFirst ¶
LowerFirst converts the first letter of a string to lowercase while leaving the rest unchanged.
func Pad ¶
Pad a string 's' with a specified 'length' by adding 'chars' on both sides. If 'char' is not provided, it defaults to a space character. The resulting padded string will have a total length of at least 'length'. If the original string length is greater than or equal to 'length', the original string is returned unchanged.
func PadEnd ¶
PadEnd pads a string 's' with a specified 'length' by adding 'char' at the end. If 'char' is not provided, it defaults to a space character. The resulting padded string will have a total length of at least 'length'. If the original string length is greater than or equal to 'length', the original string is returned unchanged.
func PadStart ¶
PadStart pads a string 's' with a specified 'length' by adding 'char' at the beginning. If 'char' is not provided, it defaults to a space character. The resulting padded string will have a total length of at least 'length'. If the original string length is greater than or equal to 'length', the original string is returned unchanged.
func ParseInt ¶
ParseInt parses an integer from the given string 's'. It returns the parsed integer value and an error if parsing fails.
func Repeat ¶
Repeat the given string 's' a specified number of 'times'. It returns the concatenated string where 's' is repeated 'times' times. If 'times' is zero or negative, an empty string is returned.
func Replace ¶
Replace occurrences of a specified 'pattern' in the string 's' with the 'replacement' string. It returns the modified string where all occurrences of 'pattern' are replaced with 'replacement'.
func SnakeCase ¶
SnakeCase converts a string to snake_case format. It replaces spaces and punctuation with underscores and converts letters to lowercase.
func Split ¶
Split a string 's' into substrings using the specified 'separator'. It returns a slice of substrings. The 'limit' parameter controls the maximum number of substrings to return. If 'limit' is negative, there is no limit.
func StartsWith ¶
StartsWith checks if the string 'str' starts with the target string 'target' optionally from the specified 'position' in 'str'. It returns true if 'str' starts with 'target', and false otherwise. If 'position' is provided, the comparison starts from that position in 'str'.
func Unescape ¶
Unescape a string that contains Escape sequences and returns the unescaped string. The input string should be surrounded by double quotes to properly Unescape it. If un-escaping fails, the original input string is returned.
func UpperCase ¶
UpperCase converts all characters in the input string 's' to uppercase. It returns the modified string with all characters in uppercase.
func UpperFirst ¶
UpperFirst converts the first letter of a string to uppercase while leaving the rest unchanged.
Types ¶
This section is empty.