strs

package
v0.0.0-...-cd4d371 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2020 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Num    Spec = 1 << iota //包含数字
	Symbol                  //包含非字母数字符号
	Upper                   //包含大写字母
	Lower                   //喊喊小写字母

	Alphabet = Upper | Lower     //字母(大写和小写)
	NoSymbol = Alphabet | Num    //字母和数字
	All      = NoSymbol | Symbol //所有字符串

)

Variables

View Source
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))
)
View Source
var HoldWords = []string{"ID", "URL", "IP"}

Functions

func Incr

func Incr() int

func Incrs

func Incrs() string

func IsEmail

func IsEmail(s string) bool

func IsMobilePhone

func IsMobilePhone(s string) bool

func RandHs

func RandHs(size int, distinct bool) string

RandHs 产生随机汉字 汉字范围: 0x4e00 - 0x9fa5 @auth 树哥<shu@aryao.com> 2020/07/17 14:03:42 @param size string 随机字符串长度 @param distinct boolean 不允许出现重复字符 @return 随机汉字

func RandSlice

func RandSlice(s []interface{})

func RandSlice2

func RandSlice2(s interface{})

func RandString

func RandString(size int, spec Spec, distinct bool) string

RandString 产生随机字符串 @auth 树哥<shu@aryao.com> 2020/07/17 14:03:42 @param size string 随机字符串长度 @param spec Spec枚举 类型 @param distinct boolean 不允许出现重复字符 @return 随机字符串

func Slugify

func Slugify(s string) string

Slugify implements make a pretty slug from the given text. e.g. Slugify("kožušček hello world") => "kozuscek-hello-world"

func SnakeCase

func SnakeCase(name string) string

func UnsafeBytes

func UnsafeBytes(s string) (b []byte)

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

func UnsafeString(b []byte) (s string)

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.

Types

type Spec

type Spec uint

Spec 随机字符串枚举类型

func ParseSpec

func ParseSpec(spec ...string) Spec

func (Spec) Len

func (s Spec) Len() int

Len 枚举包含的字符种类数量

func (Spec) String

func (s Spec) String() string

Jump to

Keyboard shortcuts

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