Documentation ¶
Overview ¶
Example ¶
SetClipboard("ab") text := GetClipboard() fmt.Println(text)
Output: ab
Index ¶
- Variables
- func AppendStr(strs []string, str string) []string
- func ArrayChunk(array interface{}, size int) []interface{}
- func Base58Decode(input []byte) []byte
- func Base58Encode(input []byte) []byte
- func ByteToHex(data []byte) string
- func ByteToString(b []byte) string
- func CompareSliceStr(s1, s2 []string) bool
- func CompareSliceStrU(s1, s2 []string) bool
- func ConcatString(s ...string) string
- func ConvertString(src string, tagCode string) string
- func ConvertToByte(key interface{}) ([]byte, error)
- func ConvertToFloat64(unk interface{}) (float64, error)
- func ConvertToString(value interface{}) (string, error)
- func DbcToSbc(str string) string
- func DecodeByte(data []byte, to interface{}) error
- func DeleteValueByIndex(obj []interface{}, idx int) []interface{}
- func EncodeByte(data interface{}) ([]byte, error)
- func ExpandTabs(str string, count int) string
- func FilterEmptyString(in []string) (out []string)
- func GenerateV1() string
- func GenerateV4() string
- func GetClipboard() string
- func GetFuncName(f interface{}) string
- func GetGBK(src string) string
- func HexStr2int(hexStr string) (int, error)
- func HexToBye(hexStr string) []byte
- func InArray(needle interface{}, haystack interface{}) bool
- func IncludesString(texts []string, text string) bool
- func Indent(str string, left string) string
- func Int2HexStr(num int) (hex string)
- func Interface2Int(value interface{}) (int, error)
- func Interface2String(value interface{}) string
- func InterfaceIsEmpty(value interface{}) bool
- func IsAlpha(s string) bool
- func IsAlphanumeric(s string) bool
- func IsChineseChar(str string) bool
- func IsContains(item string, sl []string) bool
- func IsContainsInterface(item interface{}, sl []interface{}) bool
- func IsEmail(email string) bool
- func IsEmailRFC(email string) bool
- func IsEmpty(value interface{}) bool
- func IsIDCard(cardNo string) bool
- func IsInSlice(value interface{}, sli interface{}) bool
- func IsInternalType(t string) bool
- func IsKeywords(t string) bool
- func IsLetter(l uint8) bool
- func IsNil(vi interface{}) (result bool)
- func IsNumeric(s string) bool
- func IsPhone(mobileNum string) bool
- func IsRunTesting() bool
- func IsSubset(parent []interface{}, sub []interface{}) bool
- func IsUrl(url string) bool
- func IsZero(i ...interface{}) bool
- func JoinInt(is []int64) string
- func Lcfirst(str string) string
- func LongestPalindromic(input string) string
- func MapLines(str string, fn func(string) string) string
- func Merge(s1 []string, s2 []string) []string
- func MinimumString(rest []string) string
- func NewShortUUID() string
- func Next(tableIdx int64) int64
- func Random(n int, validRunes []rune) string
- func RandomString(n int) string
- func RegexpReplace(reg, src, temp string) string
- func RemoveChar(s string, rmVal rune) string
- func RemoveSliceString(texts []string, text string) []string
- func RemoveString(s, rmStr string) string
- func ReverseArray(a []int)
- func ReverseBytes(b []byte)
- func ReverseSlice(slice []interface{}) []interface{}
- func ReverseString(s string) string
- func RuneWidth(r rune) int
- func SetClipboard(cb string)
- func Slice(s string) (b []byte)
- func SliceContains(arr []interface{}, elem interface{}) bool
- func SliceContainsInt64(sl []int64, i int64) bool
- func SliceContainsStr(sl []string, str string) bool
- func SliceContainsUint(arr []uint, e uint) bool
- func SliceContainsUint32(arr []uint32, e uint32) bool
- func SliceNotExistsUint32(currentArr []uint32, oldArr []uint32) []uint32
- func SliceShuffle(slice []interface{})
- func SnakeString(s string) string
- func Sonyflake() string
- func SplitAndMap(str string, split string, fn func(string) string) string
- func SplitInt(s string) ([]int64, error)
- func String(b []byte) (s string)
- func StringLength(str string) int
- func StringSliceContains(ss []string, s string) bool
- func StringSliceEqual(a, b []string) bool
- func StringSliceReflectEqual(a, b []string) bool
- func StringToBytes(s string) (b []byte)
- func StringToInt(str string) (int, error)
- func StringToInt64(str string) (int64, error)
- func StringToUint64(str string) (uint64, error)
- func SubString(str string, start, length int) string
- func TableIdx(id int64) int
- func TranslateString(src string, srcCode string, tagCode string) string
- func Ucfirst(str string) string
- func Uint64DeleteElemInSlice(i int, s []uint64) []uint64
- func Uint64DeleteElemInSliceWithOrder(i int, s []uint64) []uint64
- func Uint64ShuffleSlice(a []uint64) []uint64
- func Uint64SliceReverse(a []uint64) []uint64
- func UnicodeEmojiCode(s string) string
- func UnicodeEmojiDecode(s string) string
- func UniqueString(texts []string) []string
- func Width(str string) int
- func WordCount(str string) int
- func Xid() string
- type Arena
- type Error
- type Sequence
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( LowerAlpha = []rune("abcdefghijklmnopqrstuvwxyz") UpperAlpha = []rune("ABCDEFGHIJKLMNOPQRSTUVWXYZ") Digits = []rune("0123456789") Letter = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") AllLetter = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") )
Functions ¶
func ArrayChunk ¶
func ArrayChunk(array interface{}, size int) []interface{}
ArrayChunk split an array into chunks
func Base58Decode ¶ added in v0.1.1
Base58Decode decodes Base58-encoded data
func Base58Encode ¶ added in v0.1.1
Base58Encode 将二进制数组编译成base58
func ByteToString ¶ added in v0.1.1
BytesToString convert []byte type to string type.
func CompareSliceStr ¶
CompareSliceStr compares two 'string' type slices. It returns true if elements and order are both the same.
func CompareSliceStrU ¶
CompareSliceStrU compares two 'string' type slices. It returns true if elements are the same, and ignores the order.
func ConcatString ¶
ConcatString 连接字符串 NOTE: 性能比fmt.Sprintf和+号要好
func ConvertToFloat64 ¶
func ConvertToString ¶
func DeleteValueByIndex ¶ added in v0.1.1
func DeleteValueByIndex(obj []interface{}, idx int) []interface{}
* DeleteValueByIndex 删除slice中的元素
func ExpandTabs ¶
ExpandTabs converts tabs to the spaces. count specifies the number of spaces
Example ¶
fmt.Printf("%s", ExpandTabs("\tlorem\n\tipsum", 2))
Output: lorem ipsum
func FilterEmptyString ¶ added in v0.0.8
func GenerateV1 ¶
func GenerateV1() string
Generate 标准的UUID风格算法 based on timestamp and MAC address (RFC 4122)
func HexStr2int ¶
HexStr2int converts hex format string to decimal number.
func InArray ¶
func InArray(needle interface{}, haystack interface{}) bool
InArray checks if a value exists in an array
func IncludesString ¶
func Indent ¶
Indent indents every line of string str with the left parameter Empty lines are indented too.
Example ¶
fmt.Println(Indent("Lorem ipsum\ndolor sit amet", " > "))
Output: > Lorem ipsum > dolor sit amet
func Int2HexStr ¶
Int2HexStr converts decimal number to hex format string.
func Interface2Int ¶ added in v0.0.8
Interface2Int interface{} 转换成数字
func Interface2String ¶ added in v0.0.8
func Interface2String(value interface{}) string
Interface2String 对象转字符串
func InterfaceIsEmpty ¶ added in v0.0.8
func InterfaceIsEmpty(value interface{}) bool
InterfaceIsEmpty 是否是空
func IsAlphanumeric ¶ added in v0.1.1
IsAlphanumeric checks if the string contains only Unicode letters or digits.
func IsContains ¶ added in v0.1.1
* IsContains 元素是否包含
func IsContainsInterface ¶ added in v0.1.1
func IsContainsInterface(item interface{}, sl []interface{}) bool
* IsContainsInterface 元素是否包含(interface)
func IsEmailRFC ¶ added in v0.0.2
func IsInSlice ¶
func IsInSlice(value interface{}, sli interface{}) bool
IsInSlice 判断某一值是否在slice中 因为使用了反射,所以时间开销比较大,使用中根据实际情况进行选择
func IsNumeric ¶ added in v0.1.1
IsNumeric Checks if the string contains only digits. A decimal point is not a digit and returns false.
func IsSubset ¶
func IsSubset(parent []interface{}, sub []interface{}) bool
IsSubset return true if the @sub is a subset of the @parent
func LongestPalindromic ¶ added in v0.1.1
func MapLines ¶
Example ¶
fmt.Println(MapLines("Lorem\\nIpsum", strings.ToUpper))
Output: LOREM IPSUM
func NewShortUUID ¶ added in v0.0.8
func NewShortUUID() string
func RandomString ¶
func RegexpReplace ¶
func RemoveChar ¶ added in v0.1.1
RemoveChar removes all occurrences of a specified character from the string.
func RemoveSliceString ¶ added in v0.1.1
func RemoveString ¶
RemoveString removes all occurrences of a substring from the string.
func ReverseArray ¶
func ReverseArray(a []int)
func ReverseBytes ¶ added in v0.0.5
func ReverseBytes(b []byte)
func ReverseSlice ¶
func ReverseSlice(slice []interface{}) []interface{}
func SliceContains ¶
func SliceContains(arr []interface{}, elem interface{}) bool
SliceContains return true if the elem is in the array arr
func SliceContainsInt64 ¶
SliceContainsInt64 returns true if the int64 exists in given slice.
func SliceContainsStr ¶
SliceContainsStr returns true if the string exists in given slice, ignore case.
func SliceContainsUint ¶
func SliceContainsUint32 ¶
func SliceNotExistsUint32 ¶
func SnakeString ¶ added in v0.1.1
SnakeString converts the accepted string to a snake string (XxYy to xx_yy)
func StringSliceContains ¶
StringSliceContains 字符串切片中是否包含另一个字符串 来自go源码 net/http/server.go
func StringSliceEqual ¶
StringSliceEqual 判断 string和slice 是否相等 使用了传统的遍历方式
func StringSliceReflectEqual ¶
StringSliceReflectEqual 判断 string和slice 是否相等 因为使用了反射,所以效率较低,可以看benchmark结果
func StringToBytes ¶
StringToBytes convert string type to []byte type. NOTE: panic if modify the member value of the []byte.
func SubString ¶ added in v0.1.1
Example ¶
fmt.Println(SubString("hello", 1, 2)) fmt.Println(SubString("hello", 1, 0))
Output: el
func TableIdx ¶ added in v0.0.9
TableIdx get the table index from id Give a ID return idx of table shard
func TranslateString ¶
ConvertToString 字符集转换
func Uint64DeleteElemInSlice ¶
Uint64DeleteElemInSlice 从slice删除元素 fast version, 会改变顺序 i:slice的索引值 s: slice
func Uint64DeleteElemInSliceWithOrder ¶
Uint64DeleteElemInSliceWithOrder 从slice删除元素 slow version, 保持原有顺序 i:slice的索引值 s: slice
func Uint64ShuffleSlice ¶
Uint64ShuffleSlice 对slice进行随机
func Uint64SliceReverse ¶
Uint64SliceReverse 对uint64 slice 反转