Documentation
¶
Overview ¶
Package string provides a set of functions for working with strings
Index ¶
- Constants
- Variables
- func CastStringToType(input_type string, value interface{}) interface{}
- func CheckNotBlank(value ...string) error
- func Clean(str string, replace string) string
- func CommaListContainsString(string_list string, str string) bool
- func Concat(sep string, string_list ...any) string
- func CreateKey(value string, replace_with string) string
- func CreateKeyOrGUID(value string, replace_with string) (string, error)
- func GetDomainOrIP(url_str string) string
- func GetPortInt(url_str string) int
- func GetPortString(url_str string) string
- func GzipBase64(data interface{}) (string, error)
- func InsertString(orig []string, index int, value string) []string
- func IsNumber(s string) bool
- func RemoveSpacesForHyphens(value string) (string, error)
- func RemoveSpacesForUnderscores(value string) string
Constants ¶
const ( INPUT_TYPE_BOOL = "bool" INPUT_TYPE_INT = "int" INPUT_TYPE_FLOAT = "float" INPUT_TYPE_STRING = "string" )
const definitions for the input types
Variables ¶
var Err_ValueIsBlank = fmt.Errorf("a value is blank")
err definitions
Functions ¶
func CastStringToType ¶
func CastStringToType(input_type string, value interface{}) interface{}
CastStringToType casts a string to a type - input_type: the type to cast to
- INPUT_TYPE_BOOL = "bool"
- INPUT_TYPE_INT = "int"
- INPUT_TYPE_FLOAT = "float"
- value: the string to cast - returns: the cast value
func CheckNotBlank ¶
CheckNotBlank takes a list of strings and returns an error if any of the strings are blank - value: a list of strings - returns: an error if any of the strings are blank
func Clean ¶
Clean It takes a string and replaces all non-alphanumeric characters with the string passed in as the second argument - str: the string to clean - replace: the string to replace non-alphanumeric characters with - returns: the cleaned string
func CommaListContainsString ¶
CommaListContainsString returns true if a string contains any of the items in a comma separated list - string_list: the comma separated list of strings - str: the string to check - returns: true if the string contains any of the items in the comma separated list
func Concat ¶
Concat takes a string and a list of strings and returns a string. - sep: the separator to use between the strings - string_list: a list of strings to concatenate - returns: a concatenated string
func CreateKey ¶
CreateKey takes a string and returns a string that can be used as a key - value: the string to convert - replace_with: the string to replace spaces with - returns: the converted string
func CreateKeyOrGUID ¶
CreateKeyOrGUID takes a string and returns a string that can be used as a key or a GUID if the string is empty - value: the string to convert - replace_with: the string to replace spaces with - returns: the converted string - error: any error that occurs
func GetDomainOrIP ¶
GetDomainOrIP returns the domain or IP from a URL - url_str: the URL to parse - returns: the domain or IP from the URL
func GetPortInt ¶
GetPortInt returns the port from a URL as an int - url_str: the URL to parse - returns: the port from the URL as an int
func GetPortString ¶
GetPortString returns the port from a URL - url_str: the URL to parse - returns: the port from the URL
func GzipBase64 ¶
GzipBase64 It takes a string, compresses it, and then base64 encodes it
- data: the data to compress and encode as a string or []byte
- returns: the compressed and encoded data as a string and an error if there was a problem compressing or encoding the data
func InsertString ¶
InsertString inserts a string into a slice of strings - orig: the original slice of strings - index: the index to insert the string at - value: the string to insert - returns: the new slice of strings
func IsNumber ¶
IsNumber returns true if a string is a number - s: the string to check - returns: true if the string is a number
func RemoveSpacesForHyphens ¶
RemoveSpacesForHyphens It takes a string, converts it to lowercase, replaces all spaces with hyphens, and returns the string - value: the string to convert - returns: the converted string and an error if there was a problem converting the string
func RemoveSpacesForUnderscores ¶
RemoveSpacesForUnderscores It takes a string, converts it to lowercase, and replaces all spaces with underscores - value: the string to convert - returns: the converted string
Types ¶
This section is empty.