str

package
v2.2.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlphaNumericRandomString

func AlphaNumericRandomString(length int) string

func Contains

func Contains(s []string, str string) bool

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

func DefaultIfBlank(str, defaultStr string) string

DefaultIfBlank Returns either the passed in string, or if the string is whitespace, empty (""), the value of default string.

func DefaultIfNil

func DefaultIfNil(str, defaultStr string) string

DefaultIfNil Returns either the passed in string, or if the string is empty (""), the value of default string.

func DerefString

func DerefString(s *string) string

De-referencing *string to string

func GenerateRandomBytes

func GenerateRandomBytes(n int) ([]byte, error)

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

func GenerateRandomString(length int, isSpecialCharacter bool) (string, error)

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 IsBlank

func IsBlank(str string) bool

IsBlank Checks if a string is whitespace, empty ("").

func IsEmpty

func IsEmpty(str string) bool

IsEmpty Checks if a string is whitespace, empty ("").

func IsEqualsAny

func IsEqualsAny(val string, vals ...string) bool

IsEqualsAny tests whether a string equals any string provided.

func IsMatchAllSubstrings

func IsMatchAllSubstrings(str string, subs ...string) bool

`IsMatchAllSubstrings` this function will return `true` only if all substrings matches the `str`.

func IsNotBlank

func IsNotBlank(str string) bool

IsNotBlank Checks if a string is not empty (""), not null and not whitespace only.

func IsNotEmpty

func IsNotEmpty(str string) bool

IsNotEmpty Checks if a string is not empty ("").

func IsValidUrl

func IsValidUrl(urlString string) bool

IsValidUrl tests a string to determine if it is a well-structured url or not.

func LeftPadToLength

func LeftPadToLength(s string, padStr string, overallLen int) string

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

func MatchAllSubstringsInAString(str string, subs ...string) (bool, int)

`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

func RemoveLeadingZerosFromSlice(slice []string) []string

`RemoveLeadingZerosFromSlice` this fuction will remove leading "0" from a string of slice.

func RightPadToLength

func RightPadToLength(s string, padStr string, overallLen int) string

func StringToPointer

func StringToPointer(str string) *string

func Substring

func Substring(str string, i, j int) string

Substring Returns a substring of str in range(i, j). str.Substring("manju", 0, 1) output: m

func ToSnakeCase

func ToSnakeCase(s string) string

`ToSnakeCase` is a function to convert a sting into snake case.

Types

This section is empty.

Jump to

Keyboard shortcuts

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