Documentation
¶
Index ¶
- func AlphaNumericRandomString(length int) string
- func Contains(s []string, str string) bool
- func DefaultIfBlank(str, defaultStr string) string
- func DefaultIfNil(str, defaultStr string) string
- func DerefString(s *string) string
- func GenerateRandomBytes(n int) ([]byte, error)
- func GenerateRandomString(length int, isSpecialCharacter bool) (string, error)
- func IsBlank(str string) bool
- func IsEmpty(str string) bool
- func IsEqualsAny(val string, vals ...string) bool
- func IsMatchAllSubstrings(str string, subs ...string) bool
- func IsNotBlank(str string) bool
- func IsNotEmpty(str string) bool
- func IsValidUrl(urlString string) bool
- func LeftPadToLength(s string, padStr string, overallLen int) string
- func MatchAllSubstringsInAString(str string, subs ...string) (bool, int)
- func RemoveLeadingZerosFromSlice(slice []string) []string
- func RightPadToLength(s string, padStr string, overallLen int) string
- func StringToPointer(str string) *string
- func Substring(str string, i, j int) string
- func ToSnakeCase(s string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
This function just check an element is present in a slice or not. It's a linear search (O(n)) but after finding the result it will return immidiately.
func DefaultIfBlank ¶
DefaultIfBlank Returns either the passed in string, or if the string is whitespace, empty (""), the value of default string.
func DefaultIfNil ¶
DefaultIfNil Returns either the passed in string, or if the string is empty (""), the value of default string.
func GenerateRandomBytes ¶
GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GenerateRandomString ¶
GenerateRandomString returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func IsEqualsAny ¶
IsEqualsAny tests whether a string equals any string provided.
func IsMatchAllSubstrings ¶
`IsMatchAllSubstrings` this function will return `true` only if all substrings matches the `str`.
func IsNotBlank ¶
IsNotBlank Checks if a string is not empty (""), not null and not whitespace only.
func IsValidUrl ¶
IsValidUrl tests a string to determine if it is a well-structured url or not.
func LeftPadToLength ¶
This function will add extra `padStr` on the left of `s`. FYI, If `overallLen` is 20 and the actual length of `s` is 25 then this function will remove first 5 characters from the left side of `s` to make the size equal to 20.
func MatchAllSubstringsInAString ¶
`MatchSubstringsInAString` this function will return bool and number of matches. It is useful when you need to know at least one match found and do something. `matches` will return 0 or greater than 0.
func RemoveLeadingZerosFromSlice ¶
`RemoveLeadingZerosFromSlice` this fuction will remove leading "0" from a string of slice.
func StringToPointer ¶
func Substring ¶
Substring Returns a substring of str in range(i, j). str.Substring("manju", 0, 1) output: m
func ToSnakeCase ¶
`ToSnakeCase` is a function to convert a sting into snake case.
Types ¶
This section is empty.