Documentation ¶
Overview ¶
Package stringutils provides helper functions for dealing with strings.
Package stringutils provides helper functions for dealing with strings.
Index ¶
- func Base64Decode(str string) string
- func Base64Encode(str string) string
- func Base64ForURLDecode(str string) string
- func Base64ForURLEncode(unencodedText string) string
- func Contains(strlist []string, str string) bool
- func ContainsIgnoreCase(strlist []string, str string) bool
- func FindFirstParenStrings(r *regexp.Regexp, s string) []string
- func GenerateRandomASCIIString(n int) string
- func GenerateRandomAlphaOnlyString(n int) string
- func HasPrefixIgnoreCase(strlist []string, str string) bool
- func InSlice(slice []string, s string) bool
- func IsAppname(str string) bool
- func IsEmail(str string) bool
- func IsUUID(str string) bool
- func IsUsername(str string) bool
- func Marshal(obj interface{}) (string, error)
- func ReaderToBytes(stream io.Reader) []byte
- func ReaderToString(stream io.Reader) string
- func ShellQuoteArguments(args []string) string
- func ToBoolean(str string) (bool, error)
- func ToFloat(str string) (float64, error)
- func ToInt(str string) (int64, error)
- func ToString(obj interface{}) string
- func Truncate(s string, maxlen int) string
- func UUID() string
- func Unmarshal(str string, obj interface{}) error
- type StrSlice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Base64ForURLDecode ¶
Base64ForURLDecode decode string to url base64
func Base64ForURLEncode ¶
Base64ForURLEncode encode string from url base64
func ContainsIgnoreCase ¶
ContainsIgnoreCase return true if slice contains str, ignore case
func FindFirstParenStrings ¶
FindFirstParenStrings returns slice of first paren
func GenerateRandomASCIIString ¶
GenerateRandomASCIIString generates an ASCII random stirng with length n.
func GenerateRandomAlphaOnlyString ¶
GenerateRandomAlphaOnlyString generates an alphabetical random string with length n.
func HasPrefixIgnoreCase ¶
HasPrefixIgnoreCase tests whether the string str begins with prefix, ignore case.
func InSlice ¶
InSlice tests whether a string is contained in a slice of strings or not. Comparison is case insensitive
func ShellQuoteArguments ¶
ShellQuoteArguments takes a list of strings and escapes them so they will be handled right when passed as arguments to an program via a shell
Types ¶
type StrSlice ¶
type StrSlice struct {
// contains filtered or unexported fields
}
StrSlice representes a string or an array of strings. We need to override the json decoder to accept both options.
func NewStrSlice ¶
NewStrSlice creates an StrSlice based on the specified parts (as strings).
func (*StrSlice) MarshalJSON ¶
MarshalJSON Marshals (or serializes) the StrSlice into the json format. This method is needed to implement json.Marshaller.
func (*StrSlice) UnmarshalJSON ¶
UnmarshalJSON decodes the byte slice whether it's a string or an array of strings. This method is needed to implement json.Unmarshaler.