Documentation
¶
Overview ¶
Utilities for converting and manipulating data to and from strings
Index ¶
- Constants
- Variables
- func Autotype(in interface{}) interface{}
- func Camelize(in interface{}) string
- func ConvertTo(toType ConvertType, inI interface{}) (interface{}, error)
- func ConvertToBool(in interface{}) (bool, error)
- func ConvertToBytes(in interface{}) ([]byte, error)
- func ConvertToFloat(in interface{}) (float64, error)
- func ConvertToInteger(in interface{}) (int64, error)
- func ConvertToString(in interface{}) (string, error)
- func ConvertToTime(in interface{}) (time.Time, error)
- func DetectTimeFormat(in string) string
- func ElideWords(in string, wordcount uint) string
- func Hyphenate(in interface{}) string
- func IsBoolean(in interface{}) bool
- func IsBooleanFalse(in interface{}) bool
- func IsBooleanTrue(in interface{}) bool
- func IsFloat(in interface{}) bool
- func IsHexadecimal(in string, length int) bool
- func IsInteger(in interface{}) bool
- func IsMixedCase(in string) bool
- func IsNumeric(in interface{}) bool
- func IsSeparator(r rune) bool
- func IsSurroundedBy(inI interface{}, prefix string, suffix string) bool
- func IsTime(in interface{}) bool
- func LongestCommonPrefix(inputs []string) string
- func MustBool(in interface{}, fallbackOpt ...bool) bool
- func MustFloat(in interface{}, fallbackOpt ...float64) float64
- func MustInteger(in interface{}, fallbackOpt ...int64) int64
- func MustString(in interface{}, fallbackOpt ...string) string
- func MustTime(in interface{}, fallbackOpt ...time.Time) time.Time
- func PrefixEach(in []string, prefix string) []string
- func PrefixIf(in string, prefix string) string
- func RelaxedEqual(first interface{}, second interface{}) (bool, error)
- func Snakeify(in interface{}, separator rune) string
- func SplitPair(in string, delimiter string) (string, string)
- func SplitPairRight(in string, delimiter string) (string, string)
- func SplitPairRightTrailing(in string, delimiter string) (string, string)
- func SplitPairTrailing(in string, delimiter string) (string, string)
- func SplitTriple(in string, delimiter string) (string, string, string)
- func SplitWords(in string) []string
- func SuffixEach(in []string, prefix string, suffix string) []string
- func SuffixIf(in string, suffix string) string
- func Thousandify(in interface{}, separator string, decimal string) string
- func ToByteString(in interface{}, formatString ...string) (string, error)
- func ToBytes(input string) (float64, error)
- func ToString(in interface{}) (string, error)
- func ToStringSlice(in interface{}) ([]string, error)
- func TokenizeFunc(in string, tokenizer func(rune) bool, partfn func(part string) []string) []string
- func Underscore(in interface{}) string
- func Unwrap(in string, prefix string, suffix string) string
- func Wrap(in string, prefix string, suffix string) string
- func WrapEach(in []string, prefix string, suffix string) []string
- func WrapIf(in string, prefix string, suffix string) string
- type ConvertType
- type InterceptFunc
- type ScanInterceptor
- type SiPrefix
- type Uuid
Constants ¶
const ( None SiPrefix = 0 Kilo = 1 Mega = 2 Giga = 3 Tera = 4 Peta = 5 Exa = 6 Zetta = 7 Yotta = 8 )
Variables ¶
var BooleanFalseValues = utils.BooleanFalseValues
var BooleanTrueValues = utils.BooleanTrueValues
var DefaultDecimalSeparator = `.`
var DefaultThousandsSeparator = `,`
var NilStrings = utils.NilStrings
var TimeFormats = utils.TimeFormats
Functions ¶
func ConvertTo ¶
func ConvertTo(toType ConvertType, inI interface{}) (interface{}, error)
func ConvertToBool ¶
func ConvertToBytes ¶
func ConvertToFloat ¶
func ConvertToInteger ¶
func ConvertToString ¶
func ConvertToTime ¶
func DetectTimeFormat ¶
func ElideWords ¶
Truncate the given string to a certain number of words.
func IsBooleanFalse ¶
func IsBooleanFalse(in interface{}) bool
func IsBooleanTrue ¶
func IsBooleanTrue(in interface{}) bool
func IsHexadecimal ¶
Returns whether the given string is a hexadecimal number. If the string is prefixed with "0x", the prefix is removed first. If length is greater than 0, the length of the input (excluding prefix) is checked as well.
func IsMixedCase ¶
Returns whether the letters (Unicode Catgeory 'L') in a given string are homogenous in case (all upper-case or all lower-case).
func IsSeparator ¶
func IsSurroundedBy ¶
func LongestCommonPrefix ¶
func MustInteger ¶
func MustString ¶
func PrefixEach ¶
Prefix each element in the given string slice with prefix.
func RelaxedEqual ¶
func SplitPair ¶
Split the given string into two parts. If there is only one resulting part, that part will be the first return value and the second return value will be empty.
func SplitPairRight ¶
Split the given string into two parts from the right. If there is only one resulting part, that part will be the first return value and the second return value will be empty.
func SplitPairRightTrailing ¶
Split the given string into two parts. If there is only one resulting part, that part will be the second return value and the first return value will be empty.
func SplitPairTrailing ¶
Split the given string into two parts. If there is only one resulting part, that part will be the second return value and the first return value will be empty.
func SuffixEach ¶
Suffix each element in the given string slice with suffix.
func Thousandify ¶
func ToByteString ¶
func ToStringSlice ¶
func TokenizeFunc ¶
func Underscore ¶
func Underscore(in interface{}) string
Types ¶
type ConvertType ¶
type ConvertType = utils.ConvertType
func ParseType ¶
func ParseType(name string) ConvertType
type InterceptFunc ¶
type InterceptFunc func(seq []byte)
type ScanInterceptor ¶
type ScanInterceptor struct { Disabled bool // contains filtered or unexported fields }
A ScanInterceptor is used as a SplitFunc on a bufio.Scanner. It will look at the stream of bytes being scanned for specific substrings. The registered handler function associated with a substring will be called whenever it is seen in the stream. The passthrough SplitFunc is called as normal. This allows for a stream to be split and processed while also being inspected for specific content, allowing the user to react to that content as it comes by.
func NewScanInterceptor ¶
func NewScanInterceptor(passthrough bufio.SplitFunc, intercepts ...map[string]InterceptFunc) *ScanInterceptor
func (*ScanInterceptor) BytesScanned ¶
func (self *ScanInterceptor) BytesScanned() int64
Return the total number of bytes this scanner has scanned.
func (*ScanInterceptor) Intercept ¶
func (self *ScanInterceptor) Intercept(sequence string, handler InterceptFunc)
Add an intercept sequence and handler. If the sequence is already registered, its handler function will be replaced with this one.
func (*ScanInterceptor) InterceptCounts ¶
func (self *ScanInterceptor) InterceptCounts() map[string]int64
Returns a map of intercept sequences and the number of times each one was fired.