Documentation ¶
Index ¶
- Constants
- Variables
- func CallFunc(f interface{}, args ...interface{}) (results []interface{}, err error)
- func ValidFunc(f interface{}, args ...interface{}) (vf reflect.Value, vargs []reflect.Value, err error)
- type BiosInfo
- type BoardInfo
- type CallBack
- type CpuInfo
- type FileFilter
- type LkkArrCompareType
- type LkkArray
- func (ka *LkkArray) ArrayChunk(arr interface{}, size int) [][]interface{}
- func (ka *LkkArray) ArrayColumn(arr interface{}, columnKey string) []interface{}
- func (ka *LkkArray) ArrayDiff(arr1, arr2 interface{}, compareType LkkArrCompareType) map[interface{}]interface{}
- func (ka *LkkArray) ArrayFill(value interface{}, num int) []interface{}
- func (ka *LkkArray) ArrayFlip(arr interface{}) map[interface{}]interface{}
- func (ka *LkkArray) ArrayIntersect(arr1, arr2 interface{}, compareType LkkArrCompareType) map[interface{}]interface{}
- func (ka *LkkArray) ArrayKeyExists(key interface{}, arr interface{}) bool
- func (ka *LkkArray) ArrayKeys(arr interface{}) []interface{}
- func (ka *LkkArray) ArrayPad(arr interface{}, size int, item interface{}) []interface{}
- func (ka *LkkArray) ArrayPop(s *[]interface{}) interface{}
- func (ka *LkkArray) ArrayPush(s *[]interface{}, elements ...interface{}) int
- func (ka *LkkArray) ArrayRand(arr interface{}, num int) []interface{}
- func (ka *LkkArray) ArrayReverse(arr interface{}) []interface{}
- func (ka *LkkArray) ArraySearchItem(arr interface{}, condition map[string]interface{}) (res interface{})
- func (ka *LkkArray) ArraySearchMutil(arr interface{}, condition map[string]interface{}) (res []interface{})
- func (ka *LkkArray) ArrayShift(s *[]interface{}) interface{}
- func (ka *LkkArray) ArraySlice(arr interface{}, offset, size int) []interface{}
- func (ka *LkkArray) ArrayUnique(arr interface{}) []interface{}
- func (ka *LkkArray) ArrayUnshift(s *[]interface{}, elements ...interface{}) int
- func (ka *LkkArray) ArrayValues(arr interface{}, filterNil bool) []interface{}
- func (ka *LkkArray) DeleteSliceItems(val interface{}, ids ...int) (res []interface{}, del int)
- func (ka *LkkArray) Implode(delimiter string, arr interface{}) string
- func (ka *LkkArray) InArray(needle interface{}, haystack interface{}) bool
- func (ka *LkkArray) InInt64Slice(i int64, list []int64) bool
- func (ka *LkkArray) InIntSlice(i int, list []int) bool
- func (ka *LkkArray) InStringSlice(str string, list []string) bool
- func (ka *LkkArray) IsArrayOrSlice(val interface{}, chkType uint8) int
- func (ka *LkkArray) IsEqualArray(expected, actual interface{}) bool
- func (ka *LkkArray) IsMap(val interface{}) bool
- func (ka *LkkArray) JoinInts(ints []int, delimiter string) (res string)
- func (ka *LkkArray) JoinStrings(strs []string, delimiter string) (res string)
- func (ka *LkkArray) MergeMap(key2Str bool, ss ...interface{}) map[interface{}]interface{}
- func (ka *LkkArray) MergeSlice(filterNil bool, ss ...interface{}) []interface{}
- func (ka *LkkArray) Unique64Ints(ints []int64) (res []int64)
- func (ka *LkkArray) UniqueInts(ints []int) (res []int)
- func (ka *LkkArray) UniqueStrings(strs []string) (res []string)
- type LkkCaseSwitch
- type LkkConvert
- func (kc *LkkConvert) BaseConvert(number string, frombase, tobase int) (string, error)
- func (kc *LkkConvert) Bin2Dec(str string) (int64, error)
- func (kc *LkkConvert) Bin2Hex(str string) (string, error)
- func (kc *LkkConvert) Bool2Int(val bool) int
- func (kc *LkkConvert) Bool2Str(val bool) string
- func (kc *LkkConvert) Byte2Float64(bytes []byte) float64
- func (kc *LkkConvert) Byte2Hex(val []byte) string
- func (kc *LkkConvert) Byte2Hexs(val []byte) []byte
- func (kc *LkkConvert) Byte2Int64(val []byte) int64
- func (kc *LkkConvert) Bytes2Str(val []byte) string
- func (kc *LkkConvert) Dec2Bin(number int64) string
- func (kc *LkkConvert) Dec2Hex(number int64) string
- func (kc *LkkConvert) Dec2Oct(number int64) string
- func (kc *LkkConvert) Float2Str(val interface{}, decimal int) string
- func (kc *LkkConvert) Float64ToByte(val float64) []byte
- func (kc *LkkConvert) GetPointerAddrInt(variable interface{}) int64
- func (kc *LkkConvert) Gettype(v interface{}) string
- func (kc *LkkConvert) Hex2Bin(data string) (string, error)
- func (kc *LkkConvert) Hex2Byte(str string) []byte
- func (kc *LkkConvert) Hex2Dec(str string) (int64, error)
- func (kc *LkkConvert) Hexs2Byte(val []byte) []byte
- func (kc *LkkConvert) Int2Str(val interface{}) string
- func (kc *LkkConvert) Int64ToByte(val int64) []byte
- func (kc *LkkConvert) Ip2Long(ipAddress string) uint32
- func (kc *LkkConvert) IsBinary(s string) bool
- func (kc *LkkConvert) IsBool(val interface{}) bool
- func (kc *LkkConvert) IsByte(val interface{}) bool
- func (kc *LkkConvert) IsEmpty(val interface{}) bool
- func (kc *LkkConvert) IsFloat(val interface{}) bool
- func (kc *LkkConvert) IsHex(str string) bool
- func (kc *LkkConvert) IsInt(val interface{}) bool
- func (kc *LkkConvert) IsInterface(val interface{}) bool
- func (kc *LkkConvert) IsNil(val interface{}) bool
- func (kc *LkkConvert) IsNumeric(val interface{}) bool
- func (kc *LkkConvert) IsString(val interface{}) bool
- func (kc *LkkConvert) IsStruct(val interface{}) bool
- func (kc *LkkConvert) Long2Ip(properAddress uint32) string
- func (kc *LkkConvert) Oct2Dec(str string) (int64, error)
- func (kc *LkkConvert) Runes2Bytes(rs []rune) []byte
- func (kc *LkkConvert) Str2Bool(val string) (res bool)
- func (kc *LkkConvert) Str2Bytes(val string) []byte
- func (kc *LkkConvert) Str2Float32(val string) float32
- func (kc *LkkConvert) Str2Float64(val string) (res float64)
- func (kc *LkkConvert) Str2FloatStrict(val string, bitSize int, strict bool) float64
- func (kc *LkkConvert) Str2Int(val string) (res int)
- func (kc *LkkConvert) Str2Int16(val string) int16
- func (kc *LkkConvert) Str2Int32(val string) int32
- func (kc *LkkConvert) Str2Int64(val string) int64
- func (kc *LkkConvert) Str2Int8(val string) int8
- func (kc *LkkConvert) Str2IntStrict(val string, bitSize int, strict bool) int64
- func (kc *LkkConvert) Str2Uint(val string) uint
- func (kc *LkkConvert) Str2Uint16(val string) uint16
- func (kc *LkkConvert) Str2Uint32(val string) uint32
- func (kc *LkkConvert) Str2Uint64(val string) uint64
- func (kc *LkkConvert) Str2Uint8(val string) uint8
- func (kc *LkkConvert) Str2UintStrict(val string, bitSize int, strict bool) uint64
- func (kc *LkkConvert) ToBool(val interface{}) bool
- func (kc *LkkConvert) ToFloat(val interface{}) (res float64)
- func (kc *LkkConvert) ToInt(val interface{}) int
- func (kc *LkkConvert) ToStr(val interface{}) string
- type LkkDebug
- func (kd *LkkDebug) CallMethod(t interface{}, method string, args ...interface{}) ([]interface{}, error)
- func (kd *LkkDebug) DumpStacks()
- func (kd *LkkDebug) GetFuncDir() string
- func (kd *LkkDebug) GetFuncFile() string
- func (kd *LkkDebug) GetFuncLine() int
- func (kd *LkkDebug) GetFuncName(f interface{}, onlyFun ...bool) string
- func (kd *LkkDebug) GetFuncPackage(funcFile ...string) string
- func (kd *LkkDebug) GetMethod(t interface{}, method string) interface{}
- func (kd *LkkDebug) HasMethod(t interface{}, method string) bool
- type LkkEncrypt
- func (ke *LkkEncrypt) AesCBCDecrypt(cipherText, key []byte, paddingType ...LkkPKCSType) ([]byte, error)
- func (ke *LkkEncrypt) AesCBCEncrypt(clearText, key []byte, paddingType ...LkkPKCSType) ([]byte, error)
- func (ke *LkkEncrypt) AesCFBDecrypt(cipherText, key []byte) ([]byte, error)
- func (ke *LkkEncrypt) AesCFBEncrypt(clearText, key []byte) ([]byte, error)
- func (ke *LkkEncrypt) AesCTRDecrypt(cipherText, key []byte) ([]byte, error)
- func (ke *LkkEncrypt) AesCTREncrypt(clearText, key []byte) ([]byte, error)
- func (ke *LkkEncrypt) AesOFBDecrypt(cipherText, key []byte) ([]byte, error)
- func (ke *LkkEncrypt) AesOFBEncrypt(clearText, key []byte) ([]byte, error)
- func (ke *LkkEncrypt) AuthCode(str, key []byte, encode bool, expiry int64) ([]byte, int64)
- func (ke *LkkEncrypt) Base64Decode(str []byte) ([]byte, error)
- func (ke *LkkEncrypt) Base64Encode(str []byte) []byte
- func (ke *LkkEncrypt) Base64UrlDecode(data []byte) ([]byte, error)
- func (ke *LkkEncrypt) Base64UrlEncode(source []byte) []byte
- func (ke *LkkEncrypt) EasyDecrypt(val, key []byte) []byte
- func (ke *LkkEncrypt) EasyEncrypt(data, key []byte) []byte
- func (ke *LkkEncrypt) GenerateRsaKeys(bits int) (private []byte, public []byte, err error)
- func (ke *LkkEncrypt) HmacShaX(data, secret []byte, x uint16) []byte
- func (ke *LkkEncrypt) PasswordHash(password []byte, costs ...int) ([]byte, error)
- func (ke *LkkEncrypt) PasswordVerify(password, hash []byte) bool
- func (ke *LkkEncrypt) RsaPrivateDecrypt(cipherText, privateKey []byte) ([]byte, error)
- func (ke *LkkEncrypt) RsaPrivateEncrypt(clearText, privateKey []byte) ([]byte, error)
- func (ke *LkkEncrypt) RsaPublicDecrypt(cipherText, publicKey []byte) ([]byte, error)
- func (ke *LkkEncrypt) RsaPublicEncrypt(clearText, publicKey []byte) ([]byte, error)
- type LkkFile
- func (kf *LkkFile) AbsPath(fpath string) string
- func (kf *LkkFile) AppendFile(fpath string, data []byte) error
- func (kf *LkkFile) Basename(fpath string) string
- func (kf *LkkFile) ChmodBatch(fpath string, filemode, dirmode os.FileMode) (res bool)
- func (kf *LkkFile) CopyDir(source string, dest string, cover LkkFileCover) (int64, error)
- func (kf *LkkFile) CopyFile(source string, dest string, cover LkkFileCover) (int64, error)
- func (kf *LkkFile) CopyLink(source string, dest string) error
- func (kf *LkkFile) CountLines(fpath string, buffLength int) (int, error)
- func (kf *LkkFile) DelDir(dir string, delRoot bool) error
- func (kf *LkkFile) DirSize(fpath string) int64
- func (kf *LkkFile) Dirname(fpath string) string
- func (kf *LkkFile) FastCopy(source string, dest string) (int64, error)
- func (kf *LkkFile) FileSize(fpath string) int64
- func (kf *LkkFile) FileTree(fpath string, ftype LkkFileTree, recursive bool, filters ...FileFilter) []string
- func (kf *LkkFile) FormatDir(fpath string) string
- func (kf *LkkFile) FormatPath(fpath string) string
- func (kf *LkkFile) GetExt(fpath string) string
- func (kf *LkkFile) GetFileMode(fpath string) (os.FileMode, error)
- func (kf *LkkFile) GetMime(fpath string, fast bool) string
- func (kf *LkkFile) GetModTime(fpath string) (res int64)
- func (kf *LkkFile) Glob(pattern string) ([]string, error)
- func (kf *LkkFile) Img2Base64(fpath string) (string, error)
- func (kf *LkkFile) IsBinary(fpath string) bool
- func (kf *LkkFile) IsDir(fpath string) bool
- func (kf *LkkFile) IsExecutable(fpath string) bool
- func (kf *LkkFile) IsExist(fpath string) bool
- func (kf *LkkFile) IsFile(fpath string, ftype ...LkkFileType) (res bool)
- func (kf *LkkFile) IsImg(fpath string) bool
- func (kf *LkkFile) IsLink(fpath string) bool
- func (kf *LkkFile) IsReadable(fpath string) bool
- func (kf *LkkFile) IsWritable(fpath string) bool
- func (kf *LkkFile) IsZip(fpath string) bool
- func (kf *LkkFile) Md5(fpath string, length uint8) (string, error)
- func (kf *LkkFile) Mkdir(fpath string, mode os.FileMode) error
- func (kf *LkkFile) Pathinfo(fpath string, options int) map[string]string
- func (kf *LkkFile) ReadFile(fpath string) ([]byte, error)
- func (kf *LkkFile) ReadFirstLine(fpath string) string
- func (kf *LkkFile) ReadInArray(fpath string) ([]string, error)
- func (kf *LkkFile) ReadLastLine(fpath string) string
- func (kf *LkkFile) RealPath(fpath string) string
- func (kf *LkkFile) Rename(oldname, newname string) error
- func (kf *LkkFile) SafeFileName(str string) string
- func (kf *LkkFile) ShaX(fpath string, x uint16) (string, error)
- func (kf *LkkFile) TarGz(src string, dstTar string, ignorePatterns ...string) (bool, error)
- func (kf *LkkFile) Touch(fpath string, size int64) bool
- func (kf *LkkFile) UnTarGz(srcTar, dstDir string) (bool, error)
- func (kf *LkkFile) UnZip(srcZip, dstDir string) (bool, error)
- func (kf *LkkFile) Unlink(fpath string) error
- func (kf *LkkFile) WriteFile(fpath string, data []byte, perm ...os.FileMode) error
- func (kf *LkkFile) Zip(dst string, fpaths ...string) (bool, error)
- type LkkFileCover
- type LkkFileTree
- type LkkFileType
- type LkkNumber
- func (kn *LkkNumber) AbsFloat(number float64) float64
- func (kn *LkkNumber) AbsInt(number int64) int64
- func (kn *LkkNumber) Average(nums ...interface{}) (res float64)
- func (kn *LkkNumber) AverageFloat64(nums ...float64) (res float64)
- func (kn *LkkNumber) AverageInt(nums ...int) (res float64)
- func (kn *LkkNumber) ByteFormat(size float64, decimal uint8, delimiter string) string
- func (kn *LkkNumber) Ceil(value float64) float64
- func (kn *LkkNumber) Exp(x float64) float64
- func (kn *LkkNumber) Expm1(x float64) float64
- func (kn *LkkNumber) FloatEqual(f1 float64, f2 float64, decimal ...int) bool
- func (kn *LkkNumber) Floor(value float64) float64
- func (kn *LkkNumber) GeoDistance(lng1, lat1, lng2, lat2 float64) float64
- func (kn *LkkNumber) InRange(value interface{}, left interface{}, right interface{}) bool
- func (kn *LkkNumber) InRangeFloat32(value, left, right float32) bool
- func (kn *LkkNumber) InRangeFloat64(value, left, right float64) bool
- func (kn *LkkNumber) InRangeInt(value, left, right int) bool
- func (kn *LkkNumber) IsEven(val int) bool
- func (kn *LkkNumber) IsNan(val interface{}) bool
- func (kn *LkkNumber) IsNatural(value float64) bool
- func (kn *LkkNumber) IsNaturalRange(arr []int, strict bool) (res bool)
- func (kn *LkkNumber) IsNegative(value float64) bool
- func (kn *LkkNumber) IsNonNegative(value float64) bool
- func (kn *LkkNumber) IsNonPositive(value float64) bool
- func (kn *LkkNumber) IsOdd(val int) bool
- func (kn *LkkNumber) IsPositive(value float64) bool
- func (kn *LkkNumber) IsWhole(value float64) bool
- func (kn *LkkNumber) Log(x, y float64) float64
- func (kn *LkkNumber) Max(nums ...interface{}) (res float64)
- func (kn *LkkNumber) MaxFloat64(nums ...float64) (res float64)
- func (kn *LkkNumber) MaxInt(nums ...int) (res int)
- func (kn *LkkNumber) Min(nums ...interface{}) (res float64)
- func (kn *LkkNumber) MinFloat64(nums ...float64) (res float64)
- func (kn *LkkNumber) MinInt(nums ...int) (res int)
- func (kn *LkkNumber) NumSign(value float64) (res int8)
- func (kn *LkkNumber) NumberFormat(number float64, decimal uint8, point, thousand string) string
- func (kn *LkkNumber) Percent(val, total interface{}) float64
- func (kn *LkkNumber) Pi() float64
- func (kn *LkkNumber) Pow(x, y float64) float64
- func (kn *LkkNumber) Rand(min, max int) int
- func (kn *LkkNumber) RandFloat64(min, max float64) float64
- func (kn *LkkNumber) RandInt(min, max int) int
- func (kn *LkkNumber) RandInt64(min, max int64) int64
- func (kn *LkkNumber) Range(start, end int) []int
- func (kn *LkkNumber) Round(value float64) float64
- func (kn *LkkNumber) RoundPlus(value float64, precision int8) float64
- func (kn *LkkNumber) Sum(nums ...interface{}) (res float64)
- func (kn *LkkNumber) SumFloat64(nums ...float64) float64
- func (kn *LkkNumber) SumInt(nums ...int) int
- type LkkOS
- func (ko *LkkOS) Chdir(dir string) error
- func (ko *LkkOS) Chmod(filename string, mode os.FileMode) bool
- func (ko *LkkOS) Chown(filename string, uid, gid int) bool
- func (ko *LkkOS) ClientIp(req *http.Request) string
- func (ko *LkkOS) CpuUsage() (user, idle, total uint64)
- func (ko *LkkOS) DiskUsage(path string) (used, free, total uint64)
- func (ko *LkkOS) Exec(command string) (retInt int, outStr, errStr []byte)
- func (ko *LkkOS) ForceGC()
- func (ko *LkkOS) GetBiosInfo() *BiosInfo
- func (ko *LkkOS) GetBoardInfo() *BoardInfo
- func (ko *LkkOS) GetCpuInfo() *CpuInfo
- func (ko *LkkOS) GetEndian() binary.ByteOrder
- func (ko *LkkOS) GetHostByIp(ipAddress string) (string, error)
- func (ko *LkkOS) GetIPs() (ips []string)
- func (ko *LkkOS) GetIpByHostname(hostname string) (string, error)
- func (ko *LkkOS) GetIpsByDomain(domain string) ([]string, error)
- func (ko *LkkOS) GetMacAddrs() (macAddrs []string)
- func (ko *LkkOS) GetPidByPort(port int) (pid int)
- func (ko *LkkOS) GetProcessExecPath(pid int) string
- func (ko *LkkOS) GetSystemInfo() *SystemInfo
- func (ko *LkkOS) GetTempDir() string
- func (ko *LkkOS) Getcwd() (string, error)
- func (ko *LkkOS) Getenv(varname string, def ...string) string
- func (ko *LkkOS) GoMemory() uint64
- func (ko *LkkOS) HomeDir() (string, error)
- func (ko *LkkOS) Hostname() (string, error)
- func (ko *LkkOS) IsLinux() bool
- func (ko *LkkOS) IsLittleEndian() bool
- func (ko *LkkOS) IsMac() bool
- func (ko *LkkOS) IsPortOpen(host string, port interface{}, protocols ...string) bool
- func (ko *LkkOS) IsPrivateIp(address string) (bool, error)
- func (ko *LkkOS) IsProcessExists(pid int) (res bool)
- func (ko *LkkOS) IsPublicIP(ip net.IP) bool
- func (ko *LkkOS) IsWindows() bool
- func (ko *LkkOS) LocalIP() (string, error)
- func (ko *LkkOS) MemoryUsage(virtual bool) (used, free, total uint64)
- func (ko *LkkOS) OutboundIP() (string, error)
- func (ko *LkkOS) PrivateCIDR() []*net.IPNet
- func (ko *LkkOS) Pwd() string
- func (ko *LkkOS) Setenv(varname, data string) error
- func (ko *LkkOS) System(command string) (retInt int, outStr, errStr []byte)
- func (ko *LkkOS) TriggerGC()
- type LkkPKCSType
- type LkkPadType
- type LkkRandString
- type LkkString
- func (ks *LkkString) Addslashes(str string) string
- func (ks *LkkString) AtWho(text string, minLen ...int) []string
- func (ks *LkkString) Big5ToUtf8(s []byte) ([]byte, error)
- func (ks *LkkString) Br2nl(str string) string
- func (ks *LkkString) Chr(chr int) string
- func (ks *LkkString) ChunkSplit(str string, chunklen uint, end string) string
- func (ks *LkkString) ClearUrlPrefix(str string, prefix ...string) string
- func (ks *LkkString) ClearUrlSuffix(str string, suffix ...string) string
- func (ks *LkkString) ClosestWord(word string, searchs []string) (string, int)
- func (ks *LkkString) CountBase64Byte(str string) (res int)
- func (ks *LkkString) CountWords(str string) (int, map[string]int)
- func (ks *LkkString) Crc32(str string) uint32
- func (ks *LkkString) DBC2SBC(s string) string
- func (ks *LkkString) Dstrpos(str string, arr []string, chkCase bool) (bool, string)
- func (ks *LkkString) EndsWith(str, sub string, ignoreCase bool) bool
- func (ks *LkkString) Explode(str string, delimiters ...string) (res []string)
- func (ks *LkkString) FirstLetter(str string) string
- func (ks *LkkString) FormatUrl(str string) string
- func (ks *LkkString) GbkToUtf8(s []byte) ([]byte, error)
- func (ks *LkkString) GetDomain(str string, isMains ...bool) string
- func (ks *LkkString) Gravatar(email string, size uint16) string
- func (ks *LkkString) HasChinese(str string) bool
- func (ks *LkkString) HasEnglish(str string) bool
- func (ks *LkkString) HasFullWidth(str string) bool
- func (ks *LkkString) HasHalfWidth(str string) bool
- func (ks *LkkString) HasLetter(str string) bool
- func (ks *LkkString) HasSpecialChar(str string) (res bool)
- func (ks *LkkString) HasWhitespace(str string) bool
- func (ks *LkkString) HideCard(card string) string
- func (ks *LkkString) HideMobile(mobile string) string
- func (ks *LkkString) HideTrueName(name string) string
- func (ks *LkkString) Html2Text(str string) string
- func (ks *LkkString) Htmlentities(str string) string
- func (ks *LkkString) HtmlentityDecode(str string) string
- func (ks *LkkString) HttpBuildQuery(queryData url.Values) string
- func (ks *LkkString) Img2Base64(content []byte, ext ...string) string
- func (ks *LkkString) Index(str, sub string, ignoreCase bool) int
- func (ks *LkkString) IsASCII(str string) bool
- func (ks *LkkString) IsAlphaNumeric(str string) bool
- func (ks *LkkString) IsBase64(str string) bool
- func (ks *LkkString) IsBase64Image(str string) bool
- func (ks *LkkString) IsBlank(str string) bool
- func (ks *LkkString) IsChinese(str string) bool
- func (ks *LkkString) IsChineseName(str string) bool
- func (ks *LkkString) IsCreditNo(str string) (bool, string)
- func (ks *LkkString) IsDNSName(str string) bool
- func (ks *LkkString) IsDialString(str string) bool
- func (ks *LkkString) IsEmail(email string, validateHost bool) (bool, error)
- func (ks *LkkString) IsEmpty(str string) bool
- func (ks *LkkString) IsEnglish(str string, letterCase LkkCaseSwitch) bool
- func (ks *LkkString) IsHexcolor(str string) (bool, string)
- func (ks *LkkString) IsHost(str string) bool
- func (ks *LkkString) IsIP(str string) bool
- func (ks *LkkString) IsIPv4(str string) bool
- func (ks *LkkString) IsIPv6(str string) bool
- func (ks *LkkString) IsJSON(str string) bool
- func (ks *LkkString) IsLetters(str string) bool
- func (ks *LkkString) IsLower(str string) bool
- func (ks *LkkString) IsMACAddr(str string) bool
- func (ks *LkkString) IsMd5(str string) bool
- func (ks *LkkString) IsMobilecn(str string) bool
- func (ks *LkkString) IsMultibyte(str string) bool
- func (ks *LkkString) IsPhone(str string) bool
- func (ks *LkkString) IsPort(val interface{}) bool
- func (ks *LkkString) IsRGBcolor(str string) bool
- func (ks *LkkString) IsRsaPublicKey(str string, keylen int) bool
- func (ks *LkkString) IsSha1(str string) bool
- func (ks *LkkString) IsSha256(str string) bool
- func (ks *LkkString) IsSha512(str string) bool
- func (ks *LkkString) IsTel(str string) bool
- func (ks *LkkString) IsUpper(str string) bool
- func (ks *LkkString) IsUrl(str string) bool
- func (ks *LkkString) IsUrlExists(str string) bool
- func (ks *LkkString) IsUtf8(str string) bool
- func (ks *LkkString) IsWhitespaces(str string) bool
- func (ks *LkkString) IsWord(str string) bool
- func (ks *LkkString) JsonDecode(data []byte, val interface{}) error
- func (ks *LkkString) JsonEncode(val interface{}) ([]byte, error)
- func (ks *LkkString) Jsonp2Json(str string) (string, error)
- func (ks *LkkString) LastIndex(str, sub string, ignoreCase bool) int
- func (ks *LkkString) Lcfirst(str string) string
- func (ks *LkkString) Lcwords(str string) string
- func (ks *LkkString) Levenshtein(a, b *string) int
- func (ks *LkkString) Ltrim(str string, characterMask ...string) string
- func (ks *LkkString) MbStrlen(str string) int
- func (ks *LkkString) MbSubstr(str string, start int, length ...int) string
- func (ks *LkkString) Md5(str string, length uint8) string
- func (ks *LkkString) Md5Byte(str []byte, length uint8) []byte
- func (ks *LkkString) Nl2br(html string) string
- func (ks *LkkString) Ord(char string) rune
- func (ks *LkkString) ParseStr(encodedString string, result map[string]interface{}) error
- func (ks *LkkString) ParseUrl(str string, component int) (map[string]string, error)
- func (ks *LkkString) Quotemeta(str string) string
- func (ks *LkkString) Random(length uint8, rtype LkkRandString) string
- func (ks *LkkString) RawurlDecode(str string) (string, error)
- func (ks *LkkString) RawurlEncode(str string) string
- func (ks *LkkString) RemoveAfter(str, after string, include, ignoreCase bool) string
- func (ks *LkkString) RemoveBefore(str, before string, include, ignoreCase bool) string
- func (ks *LkkString) RemoveEmoji(str string) string
- func (ks *LkkString) RemoveSpace(str string, all bool) string
- func (ks *LkkString) Reverse(str string) string
- func (ks *LkkString) Rtrim(str string, characterMask ...string) string
- func (ks *LkkString) SBC2DBC(s string) string
- func (ks *LkkString) Serialize(val interface{}) ([]byte, error)
- func (ks *LkkString) ShaX(str string, x uint16) string
- func (ks *LkkString) ShaXByte(str []byte, x uint16) []byte
- func (ks *LkkString) Shuffle(str string) string
- func (ks *LkkString) SimilarText(first, second string, percent *float64) int
- func (ks *LkkString) StartsWith(str, sub string, ignoreCase bool) bool
- func (ks *LkkString) StripTags(str string) string
- func (ks *LkkString) Stripos(haystack, needle string, offset int) int
- func (ks *LkkString) Stripslashes(str string) string
- func (ks *LkkString) Strlen(str string) int
- func (ks *LkkString) Strpad(str string, fill string, max int, ptype LkkPadType) string
- func (ks *LkkString) StrpadBoth(str string, fill string, max int) string
- func (ks *LkkString) StrpadLeft(str string, fill string, max int) string
- func (ks *LkkString) StrpadRight(str string, fill string, max int) string
- func (ks *LkkString) Strpos(haystack, needle string, offset int) int
- func (ks *LkkString) Strripos(haystack, needle string, offset int) int
- func (ks *LkkString) Strrpos(haystack, needle string, offset int) int
- func (ks *LkkString) Substr(str string, start int, length ...int) string
- func (ks *LkkString) SubstrCount(str, substr string) int
- func (ks *LkkString) ToCamelCase(str string) string
- func (ks *LkkString) ToKebabCase(str string) string
- func (ks *LkkString) ToSnakeCase(str string) string
- func (ks *LkkString) Trim(str string, characterMask ...string) string
- func (ks *LkkString) TrimBOM(str []byte) []byte
- func (ks *LkkString) Ucfirst(str string) string
- func (ks *LkkString) Ucwords(str string) string
- func (ks *LkkString) UnSerialize(data []byte, registers ...interface{}) (val interface{}, err error)
- func (ks *LkkString) Uniqid(prefix string) string
- func (ks *LkkString) UrlDecode(str string) (string, error)
- func (ks *LkkString) UrlEncode(str string) string
- func (ks *LkkString) Utf8ToBig5(s []byte) ([]byte, error)
- func (ks *LkkString) Utf8ToGbk(s []byte) ([]byte, error)
- func (ks *LkkString) UuidV4() (string, error)
- func (ks *LkkString) VersionCompare(version1, version2, operator string) bool
- type LkkTime
- func (kt *LkkTime) CheckDate(year, month, day int) bool
- func (kt *LkkTime) Date(format string, ts ...interface{}) string
- func (kt *LkkTime) Day(t ...time.Time) int
- func (kt *LkkTime) DaysBetween(fromDate, toDate time.Time) int
- func (kt *LkkTime) EndOfDay(date time.Time) time.Time
- func (kt *LkkTime) EndOfMonth(date time.Time) time.Time
- func (kt *LkkTime) EndOfWeek(date time.Time, weekStartDay ...time.Weekday) time.Time
- func (kt *LkkTime) EndOfYear(date time.Time) time.Time
- func (kt *LkkTime) GetMonthDays(month int, years ...int) (days int)
- func (kt *LkkTime) Hour(t ...time.Time) int
- func (kt *LkkTime) IsDate2time(str string) (bool, int64)
- func (kt *LkkTime) MicroTime() int64
- func (kt *LkkTime) MilliTime() int64
- func (kt *LkkTime) Minute(t ...time.Time) int
- func (kt *LkkTime) Month(t ...time.Time) int
- func (kt *LkkTime) Second(t ...time.Time) int
- func (kt *LkkTime) ServiceStartime() int64
- func (kt *LkkTime) ServiceUptime() time.Duration
- func (kt *LkkTime) Sleep(t int64)
- func (kt *LkkTime) StartOfDay(date time.Time) time.Time
- func (kt *LkkTime) StartOfMonth(date time.Time) time.Time
- func (kt *LkkTime) StartOfWeek(date time.Time, weekStartDay ...time.Weekday) time.Time
- func (kt *LkkTime) StartOfYear(date time.Time) time.Time
- func (kt *LkkTime) Str2Timestamp(str string, format ...string) (int64, error)
- func (kt *LkkTime) Str2Timestruct(str string, format ...string) (time.Time, error)
- func (kt *LkkTime) UnixTime() int64
- func (kt *LkkTime) Usleep(t int64)
- func (kt *LkkTime) Year(t ...time.Time) int
- type SystemInfo
Constants ¶
const ( // Version 版本号 Version = "0.1.4" //UINT_MAX 无符号整型uint最大值 UINT_MAX = ^uint(0) //UINT_MIN 无符号整型uint最小值 UINT_MIN uint = 0 //UINT64_MAX 无符号整型uint64最大值, 18446744073709551615 UINT64_MAX = ^uint64(0) //UINT64_MIN 无符号整型uint64最小值 UINT64_MIN uint64 = 0 //INT_MAX 有符号整型int最大值 INT_MAX = int(^uint(0) >> 1) //INT_MIN 有符号整型int最小值 INT_MIN = ^INT_MAX //INT64_MAX 有符号整型int64最大值, 9223372036854775807 INT64_MAX = int64(^uint(0) >> 1) //INT64_MIN 有符号整型int64最小值, -9223372036854775808 INT64_MIN = ^INT64_MAX // FILE_COVER_ALLOW 文件覆盖,允许 FILE_COVER_ALLOW LkkFileCover = 1 // FILE_COVER_IGNORE 文件覆盖,忽略 FILE_COVER_IGNORE LkkFileCover = 0 // FILE_COVER_DENY 文件覆盖,禁止 FILE_COVER_DENY LkkFileCover = -1 // FILE_TYPE_ANY 文件类型-任意 FILE_TYPE_ANY LkkFileType = 0 // FILE_TYPE_LINK 文件类型-链接文件 FILE_TYPE_LINK LkkFileType = 1 // FILE_TYPE_REGULAR 文件类型-常规文件(不包括链接) FILE_TYPE_REGULAR LkkFileType = 2 // FILE_TYPE_COMMON 文件类型-普通文件(包括常规和链接) FILE_TYPE_COMMON LkkFileType = 3 // FILE_TREE_ALL 文件树,查找所有(包括目录和文件) FILE_TREE_ALL LkkFileTree = 3 // FILE_TREE_DIR 文件树,仅查找目录 FILE_TREE_DIR LkkFileTree = 2 // FILE_TREE_FILE 文件树,仅查找文件 FILE_TREE_FILE LkkFileTree = 1 // RAND_STRING_ALPHA 随机字符串类型,字母 RAND_STRING_ALPHA LkkRandString = 0 // RAND_STRING_NUMERIC 随机字符串类型,数值 RAND_STRING_NUMERIC LkkRandString = 1 // RAND_STRING_ALPHANUM 随机字符串类型,字母+数值 RAND_STRING_ALPHANUM LkkRandString = 2 // RAND_STRING_SPECIAL 随机字符串类型,字母+数值+特殊字符 RAND_STRING_SPECIAL LkkRandString = 3 // RAND_STRING_CHINESE 随机字符串类型,仅中文 RAND_STRING_CHINESE LkkRandString = 4 // CASE_NONE 忽略大小写 CASE_NONE LkkCaseSwitch = 0 // CASE_LOWER 检查小写 CASE_LOWER LkkCaseSwitch = 1 // CASE_UPPER 检查大写 CASE_UPPER LkkCaseSwitch = 2 // PAD_LEFT 左侧填充 PAD_LEFT LkkPadType = 0 // PAD_RIGHT 右侧填充 PAD_RIGHT LkkPadType = 1 // PAD_BOTH 两侧填充 PAD_BOTH LkkPadType = 2 // PKCS_NONE 不进行填充 PKCS_NONE LkkPKCSType = -1 // PKCS_ZERO PKCS 0值填充 PKCS_ZERO LkkPKCSType = 0 // PKCS_SEVEN 即PKCS7 PKCS_SEVEN LkkPKCSType = 7 // COMPARE_ONLY_VALUE 仅比较值 COMPARE_ONLY_VALUE LkkArrCompareType = 0 // COMPARE_ONLY_KEY 仅比较键 COMPARE_ONLY_KEY LkkArrCompareType = 1 // COMPARE_BOTH_KEYVALUE 同时比较键和值 COMPARE_BOTH_KEYVALUE LkkArrCompareType = 2 //默认浮点数精确小数位数 FLOAT_DECIMAL = 10 //AuthCode 动态密钥长度,须<32 DYNAMIC_KEY_LEN = 8 //检查连接超时的时间 CHECK_CONNECT_TIMEOUT = time.Second * 5 // 正则模式-全中文 PATTERN_CHINESE_ALL = "^[\u4e00-\u9fa5]+$" // 正则模式-中文名称 PATTERN_CHINESE_NAME = "^[\u4e00-\u9fa5][.•·\u4e00-\u9fa5]{0,30}[\u4e00-\u9fa5]$" // 正则模式-多字节字符 PATTERN_MULTIBYTE = "[^\x00-\x7F]" // 正则模式-ASCII字符 PATTERN_ASCII = "^[\x00-\x7F]+$" // 正则模式-全角字符 PATTERN_FULLWIDTH = "[^\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]" // 正则模式-半角字符 PATTERN_HALFWIDTH = "[\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]" // 正则模式-词语,不以下划线开头的中文、英文、数字、下划线 PATTERN_WORD = "^[a-zA-Z0-9\u4e00-\u9fa5][a-zA-Z0-9_\u4e00-\u9fa5]+$" // 正则模式-浮点数 PATTERN_FLOAT = `^(-?\d+)(\.\d+)?` // 正则模式-邮箱 PATTERN_EMAIL = "" /* 133-byte string literal not displayed */ // 正则模式-用户名-英文 PATTERN_USERNAMEEN = `^[a-zA-Z0-9_.]+$` // 正则模式-大陆手机号 PATTERN_MOBILECN = `^1[3-9]\d{9}$` // 正则模式-固定电话 PATTERN_TEL_FIX = `^(010|02\d{1}|0[3-9]\d{2})-\d{7,9}(-\d+)?$` // 正则模式-400或800 PATTERN_TEL_4800 = `^[48]00\d?(-?\d{3,4}){2}$` // 正则模式-座机号(固定电话或400或800) PATTERN_TELEPHONE = `(` + PATTERN_TEL_FIX + `)|(` + PATTERN_TEL_4800 + `)` // 正则模式-电话(手机或固话) PATTERN_PHONE = `(` + PATTERN_MOBILECN + `)|(` + PATTERN_TEL_FIX + `)` // 正则模式-日期时间 PATTERN_DATETIME = `^[0-9]{4}(|\-[0-9]{2}(|\-[0-9]{2}(|\s+[0-9]{2}(|:[0-9]{2}(|:[0-9]{2})))))$` // 正则模式-身份证号码,18位或15位 PATTERN_CREDIT_NO = `` /* 158-byte string literal not displayed */ // 正则模式-小写英文 PATTERN_ALPHA_LOWER = `^[a-z]+$` // 正则模式-大写英文 PATTERN_ALPHA_UPPER = `^[A-Z]+$` // 正则模式-字母和数字 PATTERN_ALPHA_NUMERIC = `^[a-zA-Z0-9]+$` // 正则模式-十六进制颜色 PATTERN_HEXCOLOR = `^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$` // 正则模式-RGB颜色 PATTERN_RGBCOLOR = "" /* 157-byte string literal not displayed */ // 正则模式-全空白字符 PATTERN_WHITESPACE_ALL = "^[[:space:]]+$" // 正则模式-带空白字符 PATTERN_WHITESPACE_HAS = ".*[[:space:]]" // 正则模式-连续空白符 PATTERN_WHITESPACE_DUPLICATE = `[[:space:]]{2,}|[\s\p{Zs}]{2,}` // 正则模式-base64字符串 PATTERN_BASE64 = "^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=|[A-Za-z0-9+\\/]{4})$" // 正则模式-base64编码图片 PATTERN_BASE64_IMAGE = `^data:\s*(image|img)\/(\w+);base64` // 正则模式-html标签 PATTERN_HTML_TAGS = `<(.|\n)*?>` // 正则模式-DNS名称 PATTERN_DNSNAME = `^([a-zA-Z0-9_]{1}[a-zA-Z0-9_-]{0,62}){1}(\.[a-zA-Z0-9_]{1}[a-zA-Z0-9_-]{0,62})*[\._]?$` // 正则模式-MD5 PATTERN_MD5 = `^(?i)([0-9a-h]{32})$` // 正则模式-SHA1 PATTERN_SHA1 = `^(?i)([0-9a-h]{40})$` // 正则模式-SHA256 PATTERN_SHA256 = `^(?i)([0-9a-h]{64})$` // 正则模式-SHA512 PATTERN_SHA512 = `^(?i)([0-9a-h]{128})$` // 正则模式-emoji表情符 PATTERN_EMOJI = `` /* 21966-byte string literal not displayed */ )
Variables ¶
var ( // Kuptime 当前服务启动时间 Kuptime = time.Now() // KFile utilities KFile LkkFile // KStr utilities KStr LkkString // KNum utilities KNum LkkNumber // KArr utilities KArr LkkArray // KTime utilities KTime LkkTime // KConv utilities KConv LkkConvert // KOS utilities KOS LkkOS // KEncr utilities KEncr LkkEncrypt // KDbug utilities KDbug LkkDebug // KPrivCidrs 私有网段的CIDR数组 KPrivCidrs []*net.IPNet // KDelimiter 本库自定义分隔符 KDelimiter = "$@#KSYS#@$" // 身份证区域 CreditArea = map[string]string{"11": "北京", "12": "天津", "13": "河北", "14": "山西", "15": "内蒙古", "21": "辽宁", "22": "吉林", "23": "黑龙江", " 31": "上海", "32": "江苏", "33": "浙江", "34": "安徽", "35": "福建", "36": "江西", "37": "山东", "41": "河南", "42": "湖北", "43": "湖南", "44": "广东", "45": "广西", "46": "海南", "50": "重庆", "51": "四川", "52": "贵州", "53": "云南", "54": "西藏", "61": "陕西", "62": "甘肃", "63": "青海", "64": "宁夏", "65": "新疆", "71": "台湾", "81": "香港", "82": "澳门", "91": "国外"} // html抽取文本要排除的标签 TextHtmlExcludeTags = []string{"head", "title", "img", "form", "textarea", "input", "select", "button", "iframe", "script", "style", "option"} // 已编译的正则 RegFormatDir = regexp.MustCompile(`[\/]{2,}`) //连续的"//"或"\\"或"\/"或"/\" RegChineseAll = regexp.MustCompile(PATTERN_CHINESE_ALL) RegChineseName = regexp.MustCompile(PATTERN_CHINESE_NAME) RegWord = regexp.MustCompile(PATTERN_WORD) RegMultiByte = regexp.MustCompile(PATTERN_MULTIBYTE) RegFullWidth = regexp.MustCompile(PATTERN_FULLWIDTH) RegHalfWidth = regexp.MustCompile(PATTERN_HALFWIDTH) RegFloat = regexp.MustCompile(PATTERN_FLOAT) RegEmail = regexp.MustCompile(PATTERN_EMAIL) RegMobilecn = regexp.MustCompile(PATTERN_MOBILECN) RegTelephone = regexp.MustCompile(PATTERN_TELEPHONE) RegPhone = regexp.MustCompile(PATTERN_PHONE) RegDatetime = regexp.MustCompile(PATTERN_DATETIME) RegCreditno = regexp.MustCompile(PATTERN_CREDIT_NO) RegAlphaLower = regexp.MustCompile(PATTERN_ALPHA_LOWER) RegAlphaUpper = regexp.MustCompile(PATTERN_ALPHA_UPPER) RegAlphaNumeric = regexp.MustCompile(PATTERN_ALPHA_NUMERIC) RegHexcolor = regexp.MustCompile(PATTERN_HEXCOLOR) RegRgbcolor = regexp.MustCompile(PATTERN_RGBCOLOR) RegWhitespace = regexp.MustCompile(`\s`) RegWhitespaceAll = regexp.MustCompile(PATTERN_WHITESPACE_ALL) RegWhitespaceHas = regexp.MustCompile(PATTERN_WHITESPACE_HAS) RegWhitespaceDuplicate = regexp.MustCompile(PATTERN_WHITESPACE_DUPLICATE) RegBase64 = regexp.MustCompile(PATTERN_BASE64) RegBase64Image = regexp.MustCompile(PATTERN_BASE64_IMAGE) RegHtmlTag = regexp.MustCompile(PATTERN_HTML_TAGS) RegDNSname = regexp.MustCompile(PATTERN_DNSNAME) RegUrlBackslashDuplicate = regexp.MustCompile(`([^:])[\/]{2,}`) //url中连续的"//"或"\\"或"\/"或"/\" RegMd5 = regexp.MustCompile(PATTERN_MD5) RegSha1 = regexp.MustCompile(PATTERN_SHA1) RegSha256 = regexp.MustCompile(PATTERN_SHA256) RegSha512 = regexp.MustCompile(PATTERN_SHA512) RegEmoji = regexp.MustCompile(PATTERN_EMOJI) RegUsernameen = regexp.MustCompile(PATTERN_USERNAMEEN) )
Functions ¶
Types ¶
type BiosInfo ¶
type BiosInfo struct { Vendor string `json:"vendor"` Version string `json:"version"` Date string `json:"date"` }
BiosInfo BIOS信息
type BoardInfo ¶
type BoardInfo struct { Name string `json:"name"` Vendor string `json:"vendor"` Version string `json:"version"` Serial string `json:"serial"` AssetTag string `json:"assettag"` }
BoardInfo Board信息
type CpuInfo ¶
type CpuInfo struct { Vendor string `json:"vendor"` Model string `json:"model"` Speed string `json:"speed"` // CPU clock rate in MHz Cache uint `json:"cache"` // CPU cache size in KB Cpus uint `json:"cpus"` // number of physical CPUs Cores uint `json:"cores"` // number of physical CPU cores Threads uint `json:"threads"` // number of logical (HT) CPU cores }
CpuInfo CPU信息
type LkkArray ¶
type LkkArray byte
LkkArray is the receiver of array utilities
func (*LkkArray) ArrayChunk ¶
ArrayChunk 将一个数组/切片分割成多个,size为每个子数组的长度.
func (*LkkArray) ArrayColumn ¶
ArrayColumn 返回数组(切片/字典)中元素指定的一列. arr的元素必须是字典; columnKey为元素的字段名; 该方法效率较低.
func (*LkkArray) ArrayDiff ¶
func (ka *LkkArray) ArrayDiff(arr1, arr2 interface{}, compareType LkkArrCompareType) map[interface{}]interface{}
ArrayDiff 计算数组(数组/切片/字典)的交集,返回在 arr1 中但不在 arr2 里的元素,注意会同时返回键. compareType为两个数组的比较方式,枚举类型,有: COMPARE_ONLY_VALUE 根据元素值比较, 返回在 arr1 中但是不在arr2 里的值; COMPARE_ONLY_KEY 根据 arr1 中的键名和 arr2 进行比较,返回不同键名的项; COMPARE_BOTH_KEYVALUE 同时比较键和值.
func (*LkkArray) ArrayFlip ¶
func (ka *LkkArray) ArrayFlip(arr interface{}) map[interface{}]interface{}
ArrayFlip 交换数组(切片/字典)中的键和值.
func (*LkkArray) ArrayIntersect ¶
func (ka *LkkArray) ArrayIntersect(arr1, arr2 interface{}, compareType LkkArrCompareType) map[interface{}]interface{}
ArrayIntersect 计算数组(数组/切片/字典)的交集,返回在 arr1 中且在 arr2 里的元素,注意会同时返回键. compareType为两个数组的比较方式,枚举类型,有: COMPARE_ONLY_VALUE 根据元素值比较, 返回在 arr1 中且在arr2 里的值; COMPARE_ONLY_KEY 根据 arr1 中的键名和 arr2 进行比较,返回相同键名的项; COMPARE_BOTH_KEYVALUE 同时比较键和值.
func (*LkkArray) ArrayKeyExists ¶
ArrayKeyExists 检查数组里是否有指定的键名或索引.
func (*LkkArray) ArrayKeys ¶
func (ka *LkkArray) ArrayKeys(arr interface{}) []interface{}
ArrayKeys 返回数组(切片/字典)中所有的键名.
func (*LkkArray) ArrayPad ¶
ArrayPad 以指定长度将一个值item填充进arr数组/切片. 若 size 为正,则填补到数组的右侧,如果为负则从左侧开始填补; 若 size 的绝对值小于或等于 arr 数组的长度则没有任何填补.
func (*LkkArray) ArrayPop ¶
func (ka *LkkArray) ArrayPop(s *[]interface{}) interface{}
ArrayPop 弹出数组最后一个元素(出栈),并返回该元素.
func (*LkkArray) ArrayReverse ¶
func (ka *LkkArray) ArrayReverse(arr interface{}) []interface{}
ArrayReverse 返回单元顺序相反的数组(仅限数组和切片).
func (*LkkArray) ArraySearchItem ¶
func (ka *LkkArray) ArraySearchItem(arr interface{}, condition map[string]interface{}) (res interface{})
ArraySearchItem 从数组中搜索对应元素(单个). arr为要查找的数组,元素必须为字典;condition为条件字典.
func (*LkkArray) ArraySearchMutil ¶
func (ka *LkkArray) ArraySearchMutil(arr interface{}, condition map[string]interface{}) (res []interface{})
ArraySearchMutil 从数组中搜索对应元素(多个). arr为要查找的数组,元素必须为字典;condition为条件字典.
func (*LkkArray) ArrayShift ¶
func (ka *LkkArray) ArrayShift(s *[]interface{}) interface{}
ArrayShift 将数组开头的元素移出数组,并返回该元素.
func (*LkkArray) ArraySlice ¶
ArraySlice 返回根据 offset 和 size 参数所指定的 arr 数组/切片中的一段切片.
func (*LkkArray) ArrayUnique ¶
func (ka *LkkArray) ArrayUnique(arr interface{}) []interface{}
ArrayUnique 移除数组中重复的值.
func (*LkkArray) ArrayUnshift ¶
ArrayUnshift 在数组开头插入一个或多个元素,返回处理之后数组的元素个数.
func (*LkkArray) ArrayValues ¶
ArrayValues 返回数组(切片/字典)中所有的值. filterNil是否过滤空元素(nil,”),true时排除空元素,false时保留空元素.
func (*LkkArray) DeleteSliceItems ¶ added in v0.1.7
DeleteSliceItems 删除数组/切片的元素,返回一个新切片. ids为多个元素的索引(0~len(val)-1); del为删除元素的数量.
func (*LkkArray) InInt64Slice ¶
InInt64Slice 是否在64位整型数组/切片内.
func (*LkkArray) InIntSlice ¶
InIntSlice 是否在整型数组/切片内.
func (*LkkArray) InStringSlice ¶
InStringSlice 是否在字符串数组/切片内.
func (*LkkArray) IsArrayOrSlice ¶
IsArrayOrSlice 检查变量是否数组或切片. chkType检查类型,枚举值有(1仅数组,2仅切片,3数组或切片);结果为-1表示非,>=0表示是
func (*LkkArray) IsEqualArray ¶
IsEqualArray 两个数组/切片是否相同(不管元素顺序). expected, actual 是要比较的数组/切片.
func (*LkkArray) JoinStrings ¶
JoinStrings 使用分隔符delimiter连接字符串数组.效率比Implode高.
func (*LkkArray) MergeSlice ¶
MergeSlice 合并一个或多个数组/切片. filterNil是否过滤空元素(nil,”),true时排除空元素,false时保留空元素;ss是元素为数组/切片的数组.
func (*LkkArray) Unique64Ints ¶
Unique64Ints 移除64位整数数组中的重复值.
func (*LkkArray) UniqueInts ¶
UniqueInts 移除整数数组中的重复值.
func (*LkkArray) UniqueStrings ¶
UniqueStrings 移除字符串数组中的重复值.
type LkkConvert ¶
type LkkConvert byte
LkkConvert is the receiver of convert utilities
func (*LkkConvert) BaseConvert ¶
func (kc *LkkConvert) BaseConvert(number string, frombase, tobase int) (string, error)
BaseConvert 进制转换,在任意进制之间转换数字. number为输入数值,frombase为原进制,tobase为结果进制.
func (*LkkConvert) Bin2Dec ¶
func (kc *LkkConvert) Bin2Dec(str string) (int64, error)
Bin2Dec 将二进制转换为十进制.
func (*LkkConvert) Bin2Hex ¶
func (kc *LkkConvert) Bin2Hex(str string) (string, error)
Bin2Hex 将二进制字符串转换为十六进制字符串.
func (*LkkConvert) Byte2Float64 ¶
func (kc *LkkConvert) Byte2Float64(bytes []byte) float64
Byte2Float64 字节切片转64位浮点数.
func (*LkkConvert) Byte2Hex ¶
func (kc *LkkConvert) Byte2Hex(val []byte) string
Byte2Hex 字节切片转16进制字符串.
func (*LkkConvert) Byte2Hexs ¶
func (kc *LkkConvert) Byte2Hexs(val []byte) []byte
Byte2Hexs 字节切片转16进制切片.
func (*LkkConvert) Byte2Int64 ¶
func (kc *LkkConvert) Byte2Int64(val []byte) int64
Byte2Int64 字节切片转64位整型.
func (*LkkConvert) Bytes2Str ¶
func (kc *LkkConvert) Bytes2Str(val []byte) string
Bytes2Str 将字节切片转换为字符串. 零拷贝,不安全.效率是string([]byte{})的百倍以上,且转换量越大效率优势越明显.
func (*LkkConvert) Dec2Hex ¶
func (kc *LkkConvert) Dec2Hex(number int64) string
Dec2Hex 将十进制转换为十六进制.
func (*LkkConvert) Float2Str ¶
func (kc *LkkConvert) Float2Str(val interface{}, decimal int) string
Float2Str 将浮点数转换为字符串,decimal为小数位数.
func (*LkkConvert) Float64ToByte ¶
func (kc *LkkConvert) Float64ToByte(val float64) []byte
Float64ToByte 64位浮点数转字节切片.
func (*LkkConvert) GetPointerAddrInt ¶
func (kc *LkkConvert) GetPointerAddrInt(variable interface{}) int64
GetPointerAddrInt 获取变量指针地址整型值.variable为变量.
func (*LkkConvert) Hex2Bin ¶
func (kc *LkkConvert) Hex2Bin(data string) (string, error)
Hex2Bin 将十六进制字符串转换为二进制字符串.
func (*LkkConvert) Hex2Byte ¶
func (kc *LkkConvert) Hex2Byte(str string) []byte
Hex2Byte 16进制字符串转字节切片.
func (*LkkConvert) Hex2Dec ¶
func (kc *LkkConvert) Hex2Dec(str string) (int64, error)
Hex2Dec 将十六进制转换为十进制.
func (*LkkConvert) Hexs2Byte ¶
func (kc *LkkConvert) Hexs2Byte(val []byte) []byte
Hexs2Byte 16进制切片转byte切片.
func (*LkkConvert) Int2Str ¶
func (kc *LkkConvert) Int2Str(val interface{}) string
Int2Str 将整数转换为字符串.
func (*LkkConvert) Int64ToByte ¶
func (kc *LkkConvert) Int64ToByte(val int64) []byte
Int64ToByte 64位整型转字节切片.
func (*LkkConvert) Ip2Long ¶
func (kc *LkkConvert) Ip2Long(ipAddress string) uint32
Ip2Long 将 IPV4 的字符串互联网协议转换成长整型数字.
func (*LkkConvert) IsInterface ¶
func (kc *LkkConvert) IsInterface(val interface{}) bool
IsInterface 变量是否接口.
func (*LkkConvert) IsNumeric ¶
func (kc *LkkConvert) IsNumeric(val interface{}) bool
IsNumeric 变量是否数值(不包含复数和科学计数法).
func (*LkkConvert) IsString ¶
func (kc *LkkConvert) IsString(val interface{}) bool
IsString 变量是否字符串.
func (*LkkConvert) IsStruct ¶
func (kc *LkkConvert) IsStruct(val interface{}) bool
IsStruct 变量是否结构体.
func (*LkkConvert) Long2Ip ¶
func (kc *LkkConvert) Long2Ip(properAddress uint32) string
Long2Ip 将长整型转化为字符串形式带点的互联网标准格式地址(IPV4).
func (*LkkConvert) Oct2Dec ¶
func (kc *LkkConvert) Oct2Dec(str string) (int64, error)
Oct2Dec 将八进制转换为十进制.
func (*LkkConvert) Runes2Bytes ¶
func (kc *LkkConvert) Runes2Bytes(rs []rune) []byte
Runes2Bytes 将[]rune转为[]byte.
func (*LkkConvert) Str2Bool ¶
func (kc *LkkConvert) Str2Bool(val string) (res bool)
Str2Bool 将字符串转换为布尔值. 1, t, T, TRUE, true, True 等字符串为真. 0, f, F, FALSE, false, False 等字符串为假.
func (*LkkConvert) Str2Bytes ¶
func (kc *LkkConvert) Str2Bytes(val string) []byte
Str2Bytes 将字符串转换为字节切片. 该方法零拷贝,但不安全.它直接转换底层指针,两者指向的相同的内存,改一个另外一个也会变. 仅当临时需将长字符串转换且不长时间保存时可以使用. 转换之后若没做其他操作直接改变里面的字符,则程序会崩溃. 如 b:=String2bytes("xxx"); b[1]='d'; 程序将panic.
func (*LkkConvert) Str2Float32 ¶
func (kc *LkkConvert) Str2Float32(val string) float32
Str2Float32 将字符串转换为float32.
func (*LkkConvert) Str2Float64 ¶
func (kc *LkkConvert) Str2Float64(val string) (res float64)
Str2Float64 将字符串转换为float64.其中"true", "TRUE", "True"为1.0 .
func (*LkkConvert) Str2FloatStrict ¶
func (kc *LkkConvert) Str2FloatStrict(val string, bitSize int, strict bool) float64
Str2FloatStrict 严格将字符串转换为浮点型. bitSize为类型位数,strict为是否严格检查.
func (*LkkConvert) Str2Int ¶
func (kc *LkkConvert) Str2Int(val string) (res int)
Str2Int 将字符串转换为int.其中"true", "TRUE", "True"为1.
func (*LkkConvert) Str2Int16 ¶
func (kc *LkkConvert) Str2Int16(val string) int16
Str2Int16 将字符串转换为int16.
func (*LkkConvert) Str2Int32 ¶
func (kc *LkkConvert) Str2Int32(val string) int32
Str2Int32 将字符串转换为int32.
func (*LkkConvert) Str2Int64 ¶
func (kc *LkkConvert) Str2Int64(val string) int64
Str2Int64 将字符串转换为int64.
func (*LkkConvert) Str2IntStrict ¶
func (kc *LkkConvert) Str2IntStrict(val string, bitSize int, strict bool) int64
Str2IntStrict 严格将字符串转换为有符号整型. bitSize为类型位数,strict为是否严格检查.
func (*LkkConvert) Str2Uint16 ¶
func (kc *LkkConvert) Str2Uint16(val string) uint16
Str2Uint16 将字符串转换为uint16.
func (*LkkConvert) Str2Uint32 ¶
func (kc *LkkConvert) Str2Uint32(val string) uint32
Str2Uint32 将字符串转换为uint32.
func (*LkkConvert) Str2Uint64 ¶
func (kc *LkkConvert) Str2Uint64(val string) uint64
Str2Uint64 将字符串转换为uint64.
func (*LkkConvert) Str2Uint8 ¶
func (kc *LkkConvert) Str2Uint8(val string) uint8
Str2Uint8 将字符串转换为uint8.
func (*LkkConvert) Str2UintStrict ¶
func (kc *LkkConvert) Str2UintStrict(val string, bitSize int, strict bool) uint64
Str2UintStrict 严格将字符串转换为无符号整型,bitSize为类型位数,strict为是否严格检查
func (*LkkConvert) ToFloat ¶
func (kc *LkkConvert) ToFloat(val interface{}) (res float64)
ToFloat 强制将变量转换为浮点型;其中true或"true"为1.0 .
func (*LkkConvert) ToInt ¶
func (kc *LkkConvert) ToInt(val interface{}) int
ToInt 强制将变量转换为整型;其中true或"true"为1.
type LkkDebug ¶
type LkkDebug byte
LkkDebug is the receiver of debug utilities
func (*LkkDebug) CallMethod ¶
func (kd *LkkDebug) CallMethod(t interface{}, method string, args ...interface{}) ([]interface{}, error)
CallMethod 调用对象的方法. 若执行成功,则结果是该方法的返回结果; 否则返回(nil, error)
func (*LkkDebug) GetFuncName ¶
GetFunctionName 获取调用方法的名称;f为目标方法;onlyFun为true时仅返回方法,不包括包名.
func (*LkkDebug) GetFuncPackage ¶
GetFuncPackage 获取调用方法或源文件的包名.funcFile为源文件路径.
type LkkEncrypt ¶
type LkkEncrypt byte
LkkEncrypt is the receiver of encrypt utilities
func (*LkkEncrypt) AesCBCDecrypt ¶
func (ke *LkkEncrypt) AesCBCDecrypt(cipherText, key []byte, paddingType ...LkkPKCSType) ([]byte, error)
AesCBCDecrypt AES-CBC密码分组链接(Cipher-block chaining)模式解密. cipherText为密文;key为密钥,长16/24/32;paddingType为填充方式,枚举(PKCS_NONE,PKCS_ZERO,PKCS_SEVEN),默认PKCS_SEVEN.
func (*LkkEncrypt) AesCBCEncrypt ¶
func (ke *LkkEncrypt) AesCBCEncrypt(clearText, key []byte, paddingType ...LkkPKCSType) ([]byte, error)
AesCBCEncrypt AES-CBC密码分组链接(Cipher-block chaining)模式加密.加密无法并行,不适合对流数据加密. clearText为明文;key为密钥,长16/24/32;paddingType为填充方式,枚举(PKCS_ZERO,PKCS_SEVEN),默认PKCS_SEVEN.
func (*LkkEncrypt) AesCFBDecrypt ¶
func (ke *LkkEncrypt) AesCFBDecrypt(cipherText, key []byte) ([]byte, error)
AesCFBDecrypt AES-CFB密文反馈(Cipher feedback)模式解密. cipherText为密文;key为密钥,长16/24/32.
func (*LkkEncrypt) AesCFBEncrypt ¶
func (ke *LkkEncrypt) AesCFBEncrypt(clearText, key []byte) ([]byte, error)
AesCFBEncrypt AES-CFB密文反馈(Cipher feedback)模式加密.适合对流数据加密. clearText为明文;key为密钥,长16/24/32.
func (*LkkEncrypt) AesCTRDecrypt ¶
func (ke *LkkEncrypt) AesCTRDecrypt(cipherText, key []byte) ([]byte, error)
AesECBDecrypt AES-CTR计算器(Counter)模式解密. cipherText为密文;key为密钥,长16/24/32.
func (*LkkEncrypt) AesCTREncrypt ¶
func (ke *LkkEncrypt) AesCTREncrypt(clearText, key []byte) ([]byte, error)
AesECBEncrypt AES-CTR计算器(Counter)模式加密. clearText为明文;key为密钥,长16/24/32.
func (*LkkEncrypt) AesOFBDecrypt ¶
func (ke *LkkEncrypt) AesOFBDecrypt(cipherText, key []byte) ([]byte, error)
AesOFBDecrypt AES-OFB输出反馈(Output feedback)模式解密. cipherText为密文;key为密钥,长16/24/32.
func (*LkkEncrypt) AesOFBEncrypt ¶
func (ke *LkkEncrypt) AesOFBEncrypt(clearText, key []byte) ([]byte, error)
AesOFBEncrypt AES-OFB输出反馈(Output feedback)模式加密.适合对流数据加密. clearText为明文;key为密钥,长16/24/32.
func (*LkkEncrypt) AuthCode ¶
AuthCode 授权码编码或解码;encode为true时编码,为false解码;expiry为有效期,秒;返回结果为加密/解密的字符串和有效期时间戳.
func (*LkkEncrypt) Base64Decode ¶
func (ke *LkkEncrypt) Base64Decode(str []byte) ([]byte, error)
Base64Decode 对使用 MIME base64 编码的数据进行解码.
func (*LkkEncrypt) Base64Encode ¶
func (ke *LkkEncrypt) Base64Encode(str []byte) []byte
Base64Encode 使用 MIME base64 对数据进行编码.
func (*LkkEncrypt) Base64UrlDecode ¶
func (ke *LkkEncrypt) Base64UrlDecode(data []byte) ([]byte, error)
Base64UrlDecode url安全的Base64Decode.
func (*LkkEncrypt) Base64UrlEncode ¶
func (ke *LkkEncrypt) Base64UrlEncode(source []byte) []byte
Base64UrlSafeEncode url安全的Base64Encode,没有'/'和'+'及结尾的'=' .
func (*LkkEncrypt) EasyDecrypt ¶
func (ke *LkkEncrypt) EasyDecrypt(val, key []byte) []byte
EasyDecrypt 简单解密. val为待解密的字符串,key为密钥.
func (*LkkEncrypt) EasyEncrypt ¶
func (ke *LkkEncrypt) EasyEncrypt(data, key []byte) []byte
EasyEncrypt 简单加密. data为要加密的原字符串,key为密钥.
func (*LkkEncrypt) GenerateRsaKeys ¶
func (ke *LkkEncrypt) GenerateRsaKeys(bits int) (private []byte, public []byte, err error)
GenerateRsaKeys 生成RSA密钥对.bits为密钥位数,通常为1024或2048.
func (*LkkEncrypt) HmacShaX ¶
func (ke *LkkEncrypt) HmacShaX(data, secret []byte, x uint16) []byte
HmacShaX HmacSHA-x加密,x为1/256/512 .
func (*LkkEncrypt) PasswordHash ¶
func (ke *LkkEncrypt) PasswordHash(password []byte, costs ...int) ([]byte, error)
PasswordHash 创建密码的散列值;costs为算法的cost,范围4~31,默认10;注意:值越大越耗时.
func (*LkkEncrypt) PasswordVerify ¶
func (ke *LkkEncrypt) PasswordVerify(password, hash []byte) bool
PasswordVerify 验证密码是否和散列值匹配.
func (*LkkEncrypt) RsaPrivateDecrypt ¶
func (ke *LkkEncrypt) RsaPrivateDecrypt(cipherText, privateKey []byte) ([]byte, error)
RsaPrivateDecrypt RSA私钥解密.比加密耗时. cipherText为密文,privateKey为私钥.
func (*LkkEncrypt) RsaPrivateEncrypt ¶
func (ke *LkkEncrypt) RsaPrivateEncrypt(clearText, privateKey []byte) ([]byte, error)
RsaPrivateEncrypt RSA私钥加密.比解密耗时. clearText为明文,privateKey为私钥.
func (*LkkEncrypt) RsaPublicDecrypt ¶
func (ke *LkkEncrypt) RsaPublicDecrypt(cipherText, publicKey []byte) ([]byte, error)
RsaPublicDecrypt RSA公钥解密. cipherText为密文,publicKey为公钥.
func (*LkkEncrypt) RsaPublicEncrypt ¶
func (ke *LkkEncrypt) RsaPublicEncrypt(clearText, publicKey []byte) ([]byte, error)
RsaPublicEncrypt RSA公钥加密. clearText为明文,publicKey为公钥.
type LkkFile ¶
type LkkFile byte
LkkFile is the receiver of file utilities
func (*LkkFile) AppendFile ¶
AppendFile 插入文件内容.
func (*LkkFile) ChmodBatch ¶
ChmodBatch 批量改变路径权限模式(包括子目录和所属文件).filemode为文件权限模式,dirmode为目录权限模式.
func (*LkkFile) CopyDir ¶
CopyDir 拷贝源目录到目标目录,cover为枚举(FILE_COVER_ALLOW、FILE_COVER_IGNORE、FILE_COVER_DENY).
func (*LkkFile) CopyFile ¶
CopyFile 拷贝源文件到目标文件,cover为枚举(FILE_COVER_ALLOW、FILE_COVER_IGNORE、FILE_COVER_DENY).
func (*LkkFile) CountLines ¶
CountLines 统计文件行数.buffLength为缓冲长度,kb.
func (*LkkFile) FileTree ¶
func (kf *LkkFile) FileTree(fpath string, ftype LkkFileTree, recursive bool, filters ...FileFilter) []string
FileTree 获取目录的文件树列表. ftype为枚举(FILE_TREE_ALL、FILE_TREE_DIR、FILE_TREE_FILE); recursive为是否递归; filters为一个或多个文件过滤器函数,FileFilter类型.
func (*LkkFile) GetFileMode ¶
GetFileMode 获取路径的权限模式.
func (*LkkFile) GetModTime ¶
GetModTime 获取文件的修改时间戳,秒.
func (*LkkFile) Img2Base64 ¶
Img2Base64 读取图片文件,并转换为base64字符串.
func (*LkkFile) IsExecutable ¶
IsExecutable 是否可执行文件.
func (*LkkFile) IsFile ¶
func (kf *LkkFile) IsFile(fpath string, ftype ...LkkFileType) (res bool)
IsFile 是否(某类型)文件,且存在. ftype为枚举(FILE_TYPE_ANY、FILE_TYPE_LINK、FILE_TYPE_REGULAR、FILE_TYPE_COMMON),默认FILE_TYPE_ANY;
func (*LkkFile) Pathinfo ¶
Pathinfo 获取文件路径的信息,options的值为-1: all; 1: dirname; 2: basename; 4: extension; 8: filename.
func (*LkkFile) ReadFirstLine ¶
ReadFirstLine 读取文件首行.
func (*LkkFile) ReadInArray ¶
ReadInArray 把整个文件读入一个数组中,每行作为一个元素.
func (*LkkFile) ReadLastLine ¶
ReadLastLine 读取文件末行.
func (*LkkFile) SafeFileName ¶
SafeFileName 将文件名转换为安全可用的字符串.
type LkkNumber ¶
type LkkNumber byte
LkkNumber is the receiver of number utilities
func (*LkkNumber) AverageFloat64 ¶
AverageFloat64 对浮点数序列求平均值.
func (*LkkNumber) AverageInt ¶
AverageInt 对整数序列求平均值.
func (*LkkNumber) ByteFormat ¶
ByteFormat 格式化文件比特大小. size为文件大小,decimal为要保留的小数位数,delimiter为数字和单位间的分隔符.
func (*LkkNumber) FloatEqual ¶
FloatEqual 比较两个浮点数是否相等.decimal为小数精确位数.
func (*LkkNumber) GeoDistance ¶
GeoDistance 获取地理距离/米. 参数分别为两点的经度和纬度.lat:-90~90,lng:-180~180.
func (*LkkNumber) InRangeFloat32 ¶
InRangeFloat32 数值是否在2个32位浮点数范围内.
func (*LkkNumber) InRangeFloat64 ¶
InRangeFloat64 数值是否在2个64位浮点数范围内.
func (*LkkNumber) InRangeInt ¶
InRangeInt 数值是否在2个整数范围内.
func (*LkkNumber) IsNaturalRange ¶ added in v0.1.7
IsNaturalRange 是否连续的自然数数组/切片,如[0,1,2,3...],其中不能有间断. strict为是否严格检查元素的顺序.
func (*LkkNumber) IsNegative ¶
IsNegative 数值是否为负数.
func (*LkkNumber) IsNonNegative ¶
IsNonNegative 数值是否为非负数.
func (*LkkNumber) IsNonPositive ¶
IsNonPositive 数值是否为非正数.
func (*LkkNumber) IsPositive ¶
IsPositive 数值是否为正数.
func (*LkkNumber) MaxFloat64 ¶
MaxFloat64 64位浮点数序列求最大值.
func (*LkkNumber) MinFloat64 ¶
MinFloat64 64位浮点数序列求最小值.
func (*LkkNumber) NumberFormat ¶
NumberFormat 以千位分隔符方式格式化一个数字. decimal为要保留的小数位数,point为小数点显示的字符,thousand为千位分隔符显示的字符.
func (*LkkNumber) RandFloat64 ¶
RandFloat64 生产一个随机float64整数.
func (*LkkNumber) Range ¶
Range 根据范围创建数组,包含指定的元素. start为起始元素值,end为末尾元素值.若start<end,返回升序的数组;若start>end,返回降序的数组.
func (*LkkNumber) SumFloat64 ¶
SumFloat64 浮点数求和.
type LkkOS ¶
type LkkOS byte
LkkOS is the receiver of OS utilities
func (*LkkOS) CpuUsage ¶
CpuUsage 获取CPU使用率(仅支持linux),单位jiffies(节拍数). user为用户态(用户进程)的运行时间, idle为空闲时间, total为累计时间.
func (*LkkOS) Exec ¶
Exec 执行一个外部命令. retInt为1时失败,为0时成功;outStr为执行命令的输出;errStr为错误输出. 命令如 "ls -a" "/bin/bash -c \"ls -a\""
func (*LkkOS) GetHostByIp ¶
GetHostByIp 获取指定的IP地址对应的主机名.
func (*LkkOS) GetIpByHostname ¶
GetIpByHostname 返回主机名对应的 IPv4地址.
func (*LkkOS) GetIpsByDomain ¶
GetIpsByHost 获取互联网域名/主机名对应的 IPv4 地址列表.
func (*LkkOS) GetMacAddrs ¶
GetMacAddrs 获取本机的Mac网卡地址列表.
func (*LkkOS) GetPidByPort ¶
GetPidByPort 根据端口号获取监听的进程PID.
func (*LkkOS) GetProcessExecPath ¶
GetProcessExecPath 根据PID获取进程的执行路径.
func (*LkkOS) IsPortOpen ¶
IsPortOpen 检查主机端口是否开放.protocols为协议名称,可选,默认tcp.
func (*LkkOS) IsPrivateIp ¶
IsPrivateIp 是否私有IP地址(ipv4/ipv6).
func (*LkkOS) IsProcessExists ¶
IsProcessExists 进程是否存在.
func (*LkkOS) MemoryUsage ¶
MemoryUsage 获取内存使用率(仅支持linux),单位字节. 参数 virtual,是否取虚拟内存. used为已用, free为空闲, total为总数.
func (*LkkOS) PrivateCIDR ¶
PrivateCIDR 获取私有网段的CIDR(无类别域间路由).
type LkkString ¶
type LkkString byte
LkkString is the receiver of string utilities
func (*LkkString) Addslashes ¶
Addslashes 使用反斜线引用字符串.
func (*LkkString) Big5ToUtf8 ¶
Big5ToUtf8 BIG5转UTF-8编码.
func (*LkkString) ChunkSplit ¶
ChunkSplit 将字符串分割成小块.str为要分割的字符,chunklen为分割的尺寸,end为行尾序列符号.
func (*LkkString) ClearUrlPrefix ¶
ClearUrlPrefix 清除URL的前缀; str为URL字符串,prefix为前缀,默认"/".
func (*LkkString) ClearUrlSuffix ¶
ClearUrlSuffix 清除URL的后缀; str为URL字符串,suffix为后缀,默认"/".
func (*LkkString) ClosestWord ¶
ClosestWord 获取与原字符串相似度最高的字符串,以及它们的编辑距离. word为原字符串,searchs为待查找的字符串数组.
func (*LkkString) CountBase64Byte ¶
CountBase64Byte 统计base64字符串大小,字节.
func (*LkkString) CountWords ¶
CountWords 统计字符串中单词的使用情况. 返回结果:单词总数;和一个字典,包含每个单词的单独统计. 因为没有分词,对中文尚未很好支持.
func (*LkkString) FirstLetter ¶
FirstLetter 获取字符串首字母.
func (*LkkString) GetDomain ¶
GetDomain 从URL字符串中获取域名. 可选参数isMains,默认为false,取完整域名;为true时,取主域名(如abc.test.com取test.com).
func (*LkkString) HasChinese ¶
HasChinese 字符串是否含有中文.
func (*LkkString) HasEnglish ¶
HasEnglish 是否含有英文字符,HasLetter的别名.
func (*LkkString) HasFullWidth ¶
HasFullWidth 是否含有全角字符.
func (*LkkString) HasHalfWidth ¶
HasHalfWidth 是否含有半角字符.
func (*LkkString) HasSpecialChar ¶
HasSpecialChar 字符串是否含有特殊字符.
func (*LkkString) HasWhitespace ¶
HasWhitespace 是否带有空白字符.
func (*LkkString) HideMobile ¶
HideMobile 隐藏手机号.
func (*LkkString) HideTrueName ¶
HideTrueName 隐藏真实名称(如姓名、账号、公司等).
func (*LkkString) Htmlentities ¶
Htmlentities 将字符转换为 HTML 转义字符.
func (*LkkString) HtmlentityDecode ¶
HtmlentityDecode 将HTML实体转换为它们对应的字符.
func (*LkkString) HttpBuildQuery ¶
HttpBuildQuery 根据参数生成 URL-encode 之后的请求字符串.
func (*LkkString) Img2Base64 ¶
Img2Base64 将字符串转换为base64图片.ext为图片扩展名,默认jpg.
func (*LkkString) IsAlphaNumeric ¶
IsAlphaNumeric 是否字母或数字.
func (*LkkString) IsBase64Image ¶
IsBase64Image 是否base64编码的图片.
func (*LkkString) IsChineseName ¶
IsChineseName 字符串是否中文名称.
func (*LkkString) IsCreditNo ¶
IsCreditNo 检查是否(15或18位)身份证号码,并返回经校验的号码.
func (*LkkString) IsDialString ¶
IsDialString 是否网络拨号字符串(形如127.0.0.1:80),用于net.Dial()检查.
func (*LkkString) IsEnglish ¶
func (ks *LkkString) IsEnglish(str string, letterCase LkkCaseSwitch) bool
IsEnglish 字符串是否纯英文.letterCase是否检查大小写,枚举值(CASE_NONE,CASE_LOWER,CASE_UPPER).
func (*LkkString) IsHexcolor ¶
IsHexcolor 检查是否十六进制颜色,并返回带"#"的修正值.
func (*LkkString) IsMobilecn ¶
IsMobilecn 检查字符串是否中国大陆手机号.
func (*LkkString) IsMultibyte ¶
IsMultibyte 字符串是否含有多字节字符.
func (*LkkString) IsRGBcolor ¶
IsRGBcolor 检查字符串是否RGB颜色格式.
func (*LkkString) IsRsaPublicKey ¶
IsRsaPublicKey 检查字符串是否RSA的公钥,keylen为密钥长度.
func (*LkkString) IsUrlExists ¶
IsUrlExists 检查URL是否存在.
func (*LkkString) IsWhitespaces ¶
IsWhitespaces 是否全部空白字符,不包括空字符串.
func (*LkkString) JsonDecode ¶
JsonDecode 对 JSON 格式的字符串进行解码,注意val使用指针. 依赖库github.com/json-iterator/go.
func (*LkkString) JsonEncode ¶
JsonEncode 对变量进行 JSON 编码. 依赖库github.com/json-iterator/go.
func (*LkkString) Jsonp2Json ¶
Jsonp2Json 将jsonp转为json串. Example: forbar({a:"1",b:2}) to {"a":"1","b":2}
func (*LkkString) Levenshtein ¶
Levenshtein 计算两个字符串之间的编辑距离.
func (*LkkString) MbSubstr ¶
MbSubstr 返回(宽字符)字符串str的子串. start 为起始位置.若值是负数,返回的结果将从 str 结尾处向前数第 abs(start) 个字符开始. length 为截取的长度.若值时负数, str 末尾处的 abs(length) 个字符将会被省略. start/length的绝对值必须<=原字符串长度.
func (*LkkString) ParseUrl ¶
ParseUrl 解析 URL,返回其组成部分. component为需要返回的组成; -1: all; 1: scheme; 2: host; 4: port; 8: user; 16: pass; 32: path; 64: query; 128: fragment .
func (*LkkString) Random ¶
func (ks *LkkString) Random(length uint8, rtype LkkRandString) string
Random 生成随机字符串. length为长度,rtype为枚举: RAND_STRING_ALPHA 字母; RAND_STRING_NUMERIC 数值; RAND_STRING_ALPHANUM 字母+数值; RAND_STRING_SPECIAL 字母+数值+特殊字符; RAND_STRING_CHINESE 仅中文.
func (*LkkString) RawurlDecode ¶
RawurlDecode 对已编码的 URL 字符串进行解码.
func (*LkkString) RawurlEncode ¶
RawurlEncode 按照 RFC 3986 对 URL 进行编码.
func (*LkkString) RemoveAfter ¶
RemoveAfter 移除after之后的字符串; include为是否移除包括after本身; ignoreCase为是否忽略大小写.
func (*LkkString) RemoveBefore ¶
RemoveBefore 移除before之前的字符串; include为是否移除包括before本身; ignoreCase为是否忽略大小写.
func (*LkkString) RemoveEmoji ¶
RemoveEmoji 移除字符串中的表情符(使用正则,效率较低).
func (*LkkString) RemoveSpace ¶
RemoveSpace 移除字符串中的空白字符. all为true时移除全部空白,为false时只替换连续的空白字符为一个空格.
func (*LkkString) SimilarText ¶
SimilarText 计算两个字符串的相似度,返回在两个字符串中匹配字符的数目;percent为相似程度百分数.
func (*LkkString) StartsWith ¶
StartsWith 字符串str是否以sub开头.
func (*LkkString) Stripos ¶
Stripos 查找字符串首次出现的位置(不区分大小写),找不到时返回-1. haystack在该字符串中进行查找,needle要查找的字符串; offset起始位置,为负数时时,搜索会从字符串结尾指定字符数开始.
func (*LkkString) Stripslashes ¶
Stripslashes 反引用一个引用字符串.
func (*LkkString) Strpad ¶
Strpad 使用fill填充str字符串到指定长度max. ptype为填充类型,枚举值(PAD_LEFT,PAD_RIGHT,PAD_BOTH).
func (*LkkString) StrpadBoth ¶
StrpadBoth 字符串两侧填充,请参考Strpad.
func (*LkkString) StrpadLeft ¶
StrpadLeft 字符串左侧填充,请参考Strpad.
func (*LkkString) StrpadRight ¶
StrpadRight 字符串右侧填充,请参考Strpad.
func (*LkkString) Strpos ¶
Strpos 查找字符串首次出现的位置,找不到时返回-1. haystack在该字符串中进行查找,needle要查找的字符串; offset起始位置,为负数时时,搜索会从字符串结尾指定字符数开始.
func (*LkkString) Substr ¶
Substr 截取字符串str的子串. start 为起始位置.若值是负数,返回的结果将从 str 结尾处向前数第 abs(start) 个字符开始. length 为截取的长度.若值时负数, str 末尾处的 abs(length) 个字符将会被省略. start/length的绝对值必须<=原字符串长度.
func (*LkkString) SubstrCount ¶
SubstrCount 计算字符串出现的次数.
func (*LkkString) ToCamelCase ¶
ToCamelCase 转为驼峰写法. 去掉包括下划线"_"和横杠"-".
func (*LkkString) ToKebabCase ¶
ToSnakeCase 转为串形写法. 使用横杠"-"连接.
func (*LkkString) ToSnakeCase ¶
ToSnakeCase 转为蛇形写法. 使用下划线"_"连接.
func (*LkkString) UnSerialize ¶
func (ks *LkkString) UnSerialize(data []byte, registers ...interface{}) (val interface{}, err error)
UnSerialize 对字符串进行反序列化;其中registers注册对象,其类型必须和Serialize的一致.
func (*LkkString) Utf8ToBig5 ¶
Utf8ToBig5 UTF-8转BIG5编码.
func (*LkkString) VersionCompare ¶
VersionCompare 对比两个版本号字符串. 在第一个版本低于第二个时,version_compare() 返回 -1;如果两者相等,返回 0;第二个版本更低时则返回 1. operator允许的操作符有: <, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <>, ne . 特定的版本字符串,将会用以下顺序处理: 未找到的任意字符串 < dev < alpha = a < beta = b < RC = rc < # < pl = p 用法: VersionCompare("1.2.3-alpha", "1.2.3RC7", '>=') ; VersionCompare("1.2.3-beta", "1.2.3pl", 'lt') ; VersionCompare("1.1_dev", "1.2any", 'eq') .
type LkkTime ¶
type LkkTime byte
LkkTime is the receiver of time utilities
func (*LkkTime) DaysBetween ¶
DaysBetween 获取两个日期的间隔天数.
func (*LkkTime) EndOfMonth ¶
EndOfMonth 获取日期中当月的结束时间.
func (*LkkTime) GetMonthDays ¶
GetMonthDays 获取指定月份的天数.years年份,可选,默认当前年份.
func (*LkkTime) IsDate2time ¶
IsDate2time 检查字符串是否日期格式,并转换为时间戳.注意,时间戳可能为负数(小于1970年时). 匹配如:
0000 0000-00 0000/00 0000-00-00 0000/00/00 0000-00-00 00 0000/00/00 00 0000-00-00 00:00 0000/00/00 00:00 0000-00-00 00:00:00 0000/00/00 00:00:00
等日期格式.
func (*LkkTime) ServiceStartime ¶
ServiceStartime 获取当前服务启动时间戳,秒.
func (*LkkTime) ServiceUptime ¶
ServiceUptime 获取当前服务运行时间,纳秒int64.
func (*LkkTime) StartOfDay ¶
StartOfDay 获取日期中当天的开始时间.
func (*LkkTime) StartOfMonth ¶
StartOfMonth 获取日期中当月的开始时间.
func (*LkkTime) StartOfWeek ¶
StartOfWeek 获取日期中当周的开始时间; weekStartDay 周几作为周的第一天,本库默认周一.
func (*LkkTime) StartOfYear ¶
StartOfYear 获取日期中当年的开始时间.
func (*LkkTime) Str2Timestamp ¶
Str2Timestamp 将字符串转换为时间戳,秒. str 为要转换的字符串; format 为该字符串的格式,默认为"2006-01-02 15:04:05" .
func (*LkkTime) Str2Timestruct ¶
Str2Time 将字符串转换为时间结构. str 为要转换的字符串; format 为该字符串的格式,默认为"2006-01-02 15:04:05" .
type SystemInfo ¶
type SystemInfo struct { ServerName string `json:"server_name"` //服务器名称 SystemOs string `json:"system_os"` //操作系统名称 Runtime int64 `json:"run_time"` //服务运行时间,纳秒 GoroutineNum int `json:"goroutine_num"` //goroutine数量 CpuNum int `json:"cpu_num"` //cpu核数 CpuUser float64 `json:"cpu_user"` //cpu用户态比率 CpuFree float64 `json:"cpu_free"` //cpu空闲比率 DiskUsed uint64 `json:"disk_used"` //已用磁盘空间,字节数 DiskFree uint64 `json:"disk_free"` //可用磁盘空间,字节数 DiskTotal uint64 `json:"disk_total"` //总磁盘空间,字节数 MemUsed uint64 `json:"mem_used"` //已用内存,字节数 MemSys uint64 `json:"mem_sys"` //系统内存占用量,字节数 MemFree uint64 `json:"mem_free"` //剩余内存,字节数 MemTotal uint64 `json:"mem_total"` //总内存,字节数 AllocGolang uint64 `json:"alloc_golang"` //golang内存使用量,字节数 AllocTotal uint64 `json:"alloc_total"` //总分配的内存,字节数 Lookups uint64 `json:"lookups"` //指针查找次数 Mallocs uint64 `json:"mallocs"` //内存分配次数 Frees uint64 `json:"frees"` //内存释放次数 LastGCTime uint64 `json:"last_gc_time"` //上次GC时间,纳秒 NextGC uint64 `json:"next_gc"` //下次GC内存回收量,字节数 PauseTotalNs uint64 `json:"pause_total_ns"` //GC暂停时间总量,纳秒 PauseNs uint64 `json:"pause_ns"` //上次GC暂停时间,纳秒 }
SystemInfo 系统信息