Documentation ¶
Index ¶
- Constants
- Variables
- func Incr() int
- func Incrs() string
- func IsEmail(s string) bool
- func IsMobilePhone(s string) bool
- func RandHs(size int, distinct bool) string
- func RandSlice(s []interface{})
- func RandSlice2(s interface{})
- func RandString(size int, spec Spec, distinct bool) string
- func Slugify(s string) string
- func SnakeCase(name string) string
- func UnsafeBytes(s string) (b []byte)
- func UnsafeString(b []byte) (s string)
- type Spec
Constants ¶
Variables ¶
var ( // Separator separator between words Separator = "-" // SeparatorForRe for regexp SeparatorForRe = regexp.QuoteMeta(Separator) // ReInValidChar match invalid slug string ReInValidChar = regexp.MustCompile(fmt.Sprintf("[^%sa-zA-Z0-9]", SeparatorForRe)) // ReDupSeparatorChar match duplicate separator string ReDupSeparatorChar = regexp.MustCompile(fmt.Sprintf("%s{2,}", SeparatorForRe)) )
var HoldWords = []string{"ID", "URL", "IP"}
Functions ¶
func IsMobilePhone ¶
func RandHs ¶
RandHs 产生随机汉字 汉字范围: 0x4e00 - 0x9fa5 @auth 树哥<shu@aryao.com> 2020/07/17 14:03:42 @param size string 随机字符串长度 @param distinct boolean 不允许出现重复字符 @return 随机汉字
func RandSlice2 ¶
func RandSlice2(s interface{})
func RandString ¶
RandString 产生随机字符串 @auth 树哥<shu@aryao.com> 2020/07/17 14:03:42 @param size string 随机字符串长度 @param spec Spec枚举 类型 @param distinct boolean 不允许出现重复字符 @return 随机字符串
func Slugify ¶
Slugify implements make a pretty slug from the given text. e.g. Slugify("kožušček hello world") => "kozuscek-hello-world"
func UnsafeBytes ¶
UnsafeBytes returns an unsafe bytes slice reference of s. The caller must treat returned slice as immutable.
WARNING: Use carefully. The returned result must not leak to the end user.
func UnsafeString ¶
UnsafeString returns an unsafe string reference of b. The caller must treat the input slice as immutable.
WARNING: Use carefully. The returned result must not leak to the end user unless the input slice is provably immutable.