Documentation ¶
Index ¶
- Constants
- Variables
- func B64Encode(str string) string
- func Base64(str string) string
- func Bool(s string) (bool, error)
- func Camel(s string, sep ...string) string
- func CamelCase(s string, sep ...string) string
- func FilterEmail(s string) string
- func GenMd5(src interface{}) string
- func Int(s string) (int, error)
- func LowerFirst(s string) string
- func Lowercase(s string) string
- func Md5(src interface{}) string
- func MustBool(s string) bool
- func MustInt(s string) int
- func MustString(in interface{}) string
- func PadLeft(s, pad string, length int) string
- func PadRight(s, pad string, length int) string
- func Padding(s, pad string, length int, pos uint8) string
- func PrettyJSON(v interface{}) (string, error)
- func RandomBytes(length int) ([]byte, error)
- func RandomString(length int) (string, error)
- func RenderTemplate(input string, data interface{}, fns template.FuncMap, isFile ...bool) string
- func RenderText(input string, data interface{}, fns template.FuncMap, isFile ...bool) string
- func Repeat(s string, times int) string
- func RepeatRune(char rune, times int) (chars []rune)
- func Replaces(str string, pairs map[string]string) string
- func Similarity(s, t string, rate float32) (float32, bool)
- func Snake(s string, sep ...string) string
- func SnakeCase(s string, sep ...string) string
- func Split(s, sep string) (ss []string)
- func String(val interface{}) (string, error)
- func Substr(s string, pos, length int) string
- func ToArray(s string, sep ...string) []string
- func ToBool(s string) (bool, error)
- func ToInt(s string) (int, error)
- func ToIntSlice(s string, sep ...string) (ints []int, err error)
- func ToInts(s string, sep ...string) ([]int, error)
- func ToSlice(s string, sep ...string) []string
- func ToString(val interface{}) (str string, err error)
- func ToTime(s string, layouts ...string) (t time.Time, err error)
- func Trim(s string, cutSet ...string) string
- func TrimLeft(s string, cutSet ...string) string
- func TrimRight(s string, cutSet ...string) string
- func URLDecode(s string) string
- func URLEncode(s string) string
- func UpperFirst(s string) string
- func UpperWord(s string) string
- func Uppercase(s string) string
- type SimilarComparator
Constants ¶
View Source
const ( PosLeft uint8 = iota PosRight )
Position for padding string
Variables ¶
View Source
var ( // EscapeJS escape javascript string EscapeJS = template.JSEscapeString // EscapeHTML escape html string EscapeHTML = template.HTMLEscapeString )
Some alias methods.
Functions ¶
func CamelCase ¶ added in v0.2.2
CamelCase convert string to camel case. Support:
"range_price" -> "rangePrice" "range price" -> "rangePrice" "range-price" -> "rangePrice"
func FilterEmail ¶ added in v0.2.2
FilterEmail filter email, clear invalid chars.
func MustString ¶ added in v0.2.2
func MustString(in interface{}) string
MustString convert value to string
func PrettyJSON ¶
PrettyJSON get pretty Json string Deprecated
please use fmtutil.PrettyJSON() or jsonutil.Pretty() instead it
func RandomString ¶
RandomString generate. Example: this will give us a 44 byte, base64 encoded output
token, err := RandomString(32) if err != nil { // Serve an appropriately vague error to the // user, but log the details internally. }
func RenderTemplate ¶
RenderTemplate render text template
func RenderText ¶ added in v0.2.4
RenderText render text template
func RepeatRune ¶
RepeatRune repeat a rune char.
func Replaces ¶
Replaces replace multi strings
pairs: {old1: new1, old2: new2, ...}
Can also use:
strings.NewReplacer("old1", "new1", "old2", "new2").Replace(str)
func ToIntSlice ¶ added in v0.2.2
ToIntSlice split string to slice and convert item to int.
Types ¶
type SimilarComparator ¶
type SimilarComparator struct {
// contains filtered or unexported fields
}
SimilarComparator definition links:
https://github.com/mkideal/cli/blob/master/fuzzy.go
Click to show internal directories.
Click to hide internal directories.