string_utils

package
v1.49.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2022 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConcatP

func ConcatP(args ...*string) string

ConcatP concatenates all specified non-empty strings with ", " separators

func Equal

func Equal(a string, b string) bool

func Float64ToString

func Float64ToString(number float64, precision int) string

func Float64ToStringWithPrec

func Float64ToStringWithPrec(number float64, prec int) string

func FormatPhoneNumber

func FormatPhoneNumber(phoneNumber string) string

func Int64SliceToString

func Int64SliceToString(numbers []int64) string

func Int64SliceToStringSlice

func Int64SliceToStringSlice(numbers []int64) []string

func Int64ToString

func Int64ToString(number int64) string

func IntToString

func IntToString(number int) string

func IsAlphaNumeric

func IsAlphaNumeric(str string) bool

func IsAlphaNumericOrDash

func IsAlphaNumericOrDash(str string) bool

func IsEmpty

func IsEmpty(sp *string) bool

func IsNumericString

func IsNumericString(s string) bool

IsNumericString returns true if the string can be converted to a float without error

func IsSnakeCase

func IsSnakeCase(name string) bool

func IsUrlStrict added in v1.12.0

func IsUrlStrict(str string) bool

IsUrlStrict Returns whether a URL is valid in a strict way (Must have scheme and host)

func IsValidEmail added in v1.31.0

func IsValidEmail(email string) bool

func IsValidUsername

func IsValidUsername(str string) bool

func KeyToHumanReadable

func KeyToHumanReadable(s string) string

func LimitStringToMaxLength added in v1.19.0

func LimitStringToMaxLength(str string, maxLen int) string

func PascalCaseToSentence added in v1.35.0

func PascalCaseToSentence(pascal string) string

func PtoString

func PtoString(stringPointer *string) string

func RemoveAllWhiteSpaces

func RemoveAllWhiteSpaces(s string) string

func RemoveUrlScheme

func RemoveUrlScheme(str string) string

RemoveUrlScheme Removes http:// or https:// from a URL

func ReplaceCaseInsensitive

func ReplaceCaseInsensitive(string, toReplace, replaceWith string) string

func ReplaceNonSpacingMarks

func ReplaceNonSpacingMarks(str string) string

ReplaceNonSpacingMarks removes diacritics e.g. êžů becomes ezu

func SentenceCase added in v1.35.0

func SentenceCase(str string) string

func SnakeToKebabString

func SnakeToKebabString(s string) string

func SplitString

func SplitString(str string, sep []rune) []string

SplitString separates a string on any character in the list of sep

func StandardisePhoneNumber

func StandardisePhoneNumber(number string) string

StandardisePhoneNumber standardises phone numbers with +27 instead of 0 prefix

func StringToFloat64

func StringToFloat64(stringValue string) (float64, error)

func StringToInt

func StringToInt(stringValue string) (int, error)

func StringToInt64

func StringToInt64(stringValue string) (int64, error)

func StringTrimQuotes

func StringTrimQuotes(stringToTrim string) string

StringTrimQuotes - trims quotes from a string (ie: "foo" will return foo)

func StripQueryString added in v1.25.0

func StripQueryString(inputUrl string) (string, error)

StripQueryString - Strips the query parameters from a URL

func ToJSONString

func ToJSONString(object interface{}) (string, error)

func TrimP

func TrimP(sp *string) *string

TrimP trims specified strings, replacing empty string with nil

func TrimQuotes

func TrimQuotes(stringToTrim string) string

TrimQuotes - trims quotes from a string (ie: "foo" will return foo)

func UnwrapString

func UnwrapString(s *string) string

func ValidateStringAsInt64

func ValidateStringAsInt64(stringValue string) error

Types

type KeyReader

type KeyReader interface {
	Keys(prefix string) []string
	GetString(key string) (value string, ok bool)
}

KeyReader is an interface to read string "<key>":"<value>" pairs which is common to read from the environment it is abstracted so the same interface can be implemented for reading for example from REDIS and other sources

func EnvironmentKeyReader

func EnvironmentKeyReader() KeyReader

Jump to

Keyboard shortcuts

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