Documentation
¶
Index ¶
- Constants
- func CompareIntSlice(a, b []int) bool
- func CreateDir(dirPath string) (err error)
- func DateStringToIntYear(dateStr string) int
- func DateStringToTime(dateStr string) (t time.Time)
- func DirIsExist(dirPath string) bool
- func ExtractCnChar(content string) (result string)
- func ExtractEnChar(content string) (result string)
- func ExtractNameChar(content string) (result string)
- func ExtractNumChar(content string) (result string)
- func ExtractNumEnCnChar(content string) (result string)
- func Fen2YuanInt64(price int64) int64
- func Fen2YuanString(price int64) string
- func FileIsExist(filePath string) bool
- func Float64Yuan2FenInt64(price float64) int64
- func GenerateUUID() string
- func GetIntMonth() int
- func GetIntYear() int
- func GetIp() (ip string)
- func If[K comparable](cond bool, Then K, Else K) K
- func InitLocalCache(maxSizeMB int)
- func Int64ToDateString(timeUnix int64) string
- func Int64ToTimeString(timeUnix int64) string
- func InterfaceToDuration(data interface{}) time.Duration
- func InterfaceToInt64(data interface{}) int64
- func InterfaceToString(data interface{}) string
- func IsNum(s string) bool
- func IsRecordNotFoundError(err error) bool
- func IsSliceInt(val int, slice []int) bool
- func IsSliceInt64(val int64, slice []int64) bool
- func IsSliceString(val string, slice []string) bool
- func MD5(str string) string
- func PageNum(total, pageSize int) (pageNum int)
- func Random(min, max int) int
- func ReadBigFile(filePath string, handle func(string)) error
- func ReadBinaryFile(filePath string, handle func(string)) error
- func ReadFile(filePath string) (content []byte)
- func ReadLine(filePath string) (result []string)
- func RemoveReplicaSliceInt(slc []int) []int
- func RemoveReplicaSliceString(slc []string) []string
- func Sha1(str string) string
- func SliceStringToString(content []string) (result string)
- func StringToSliceString(content string) (result []string)
- func StringToTime(timeStr string) (t time.Time)
- func StringYuan2FenInt64(price string) int64
- func StructSort(list []interface{}, field string, order string)
- func TimeFormat(t time.Time) string
- func Utf8StrCut(content string, length int) string
- func VerifyMobileFormat(mobileNum string) bool
- func WriteFile(filePath, content string, append bool) bool
- type Bucket
- type LocalCache
- type Set
- type UUID
- type Variant
- type Version
Constants ¶
const ( Invalid = Variant(iota) // Invalid UUID RFC4122 // The variant specified in RFC4122 Reserved // Reserved, NCS backward compatibility. Microsoft // Reserved, Microsoft Corporation backward compatibility. Future // Reserved for future definition. )
Constants returned by Variant.
Variables ¶
This section is empty.
Functions ¶
func CompareIntSlice ¶
CompareIntSlice 比较两个int型切片是否相等, true:相等, false:不相等
func GenerateUUID ¶
func GenerateUUID() string
func If ¶
func If[K comparable](cond bool, Then K, Else K) K
func InitLocalCache ¶
func InitLocalCache(maxSizeMB int)
func Int64ToDateString ¶
func Int64ToTimeString ¶
func InterfaceToDuration ¶
func InterfaceToInt64 ¶
func InterfaceToInt64(data interface{}) int64
func InterfaceToString ¶
func InterfaceToString(data interface{}) string
func IsRecordNotFoundError ¶
func IsSliceInt ¶
func ReadBigFile ¶
ReadBigFile 大文件读取 适合:常规带换行符,单行没有超过4069个字节的
func ReadBinaryFile ¶
ReadBinaryFile 大文件读取 适合:读取二进制文件,如音频视频流
func RemoveReplicaSliceString ¶
* * slice(string类型)元素去重
func StructSort ¶
按照字段排序,需要注意是否有该字段和字段类型
Types ¶
type Bucket ¶
type Bucket struct { Slice []interface{} //承载以任意结构体为元素构成的Slice By func(p, q *interface{}) bool //排序规则函数,当需要对新的结构体slice进行排序时,只需定义这个函数即可 }
通用结构体排序 结构体排序,必须重写数组Len() Swap() Less()函数
type LocalCache ¶
type LocalCache struct { CacheSize int // contains filtered or unexported fields }
LocalCache 使用了freecache、支持缓存淘汰、线程安全
var LocalCacheInstance LocalCache
func (*LocalCache) Del ¶
func (l *LocalCache) Del(key string)
func (*LocalCache) Get ¶
func (l *LocalCache) Get(key string) string
func (*LocalCache) Set ¶
func (l *LocalCache) Set(key, value string, expire int)
type Set ¶
type Set[K comparable] struct { // contains filtered or unexported fields }
Set 不支持并发操作的Set
func NewSet ¶
func NewSet[K comparable](items ...K) *Set[K]
type UUID ¶
type UUID [16]byte
A UUID is a 128 bit (16 byte) Universal Unique IDentifier as defined in RFC 4122.
func NewRandom ¶
NewRandom returns a Random (Version 4) UUID.
The strength of the UUIDs is based on the strength of the crypto/rand package.
Uses the randomness pool if it was enabled with EnableRandPool.
A note about uniqueness derived from the UUID Wikipedia entry:
Randomly generated UUIDs have 122 random bits. One's annual risk of being hit by a meteorite is estimated to be one chance in 17 billion, that means the probability is about 0.00000000006 (6 × 10−11), equivalent to the odds of creating a few tens of trillions of UUIDs in a year and having one duplicate.
func (UUID) String ¶
String returns the string form of uuid, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx , or "" if uuid is invalid.
func (UUID) URN ¶
URN returns the RFC 2141 URN form of uuid, urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, or "" if uuid is invalid.