Documentation ¶
Overview ¶
Package zlib provides ...
Package zlib provides ...
Package zlib provides ...
Package zlib provides ...
Index ¶
- Constants
- Variables
- func AbsFloat(number float64) float64
- func AbsInt(number int64) int64
- func AbsInt16(n int16) int16
- func AbsInt32(n int32) int32
- func AbsInt64(n int64) int64
- func AbsInt8(n int8) int8
- func AbsPath(fpath string) string
- func AddDay(t time.Time, day int) time.Time
- func AddHour(t time.Time, hour int) time.Time
- func AddMinutes(t time.Time, minutes int) time.Time
- func AddMonth(t time.Time, month int) time.Time
- func AddNanoseconds(t time.Time, nanoSeconds int) time.Time
- func AddSeconds(t time.Time, seconds int) time.Time
- func AddYear(t time.Time, year int) time.Time
- func Addslashes(str string) string
- func AesDecrypt(decryptStr string, key []byte, iv string) (string, error)
- func AesEncrypt(encryptStr string, key []byte, iv string) (string, error)
- func After(n int, fn interface{}) func(args ...interface{}) []reflect.Value
- func AppendFile(fpath string, data []byte) error
- func Array2String(array []interface{}) string
- func ArrayChunk(arr interface{}, size int) [][]interface{}
- func ArrayColumn(arr interface{}, columnKey string) []interface{}
- func ArrayDiff(arr1, arr2 interface{}, compareType LkkArrCompareType) map[interface{}]interface{}
- func ArrayFlip(arr interface{}) map[interface{}]interface{}
- func ArrayInterfaceToString(_array interface{}) string
- func ArrayIntersect(arr1, arr2 interface{}, compareType LkkArrCompareType) map[interface{}]interface{}
- func ArrayKeyExists(key interface{}, arr interface{}) bool
- func ArrayKeys(arr interface{}) []interface{}
- func ArrayPad(arr interface{}, size int, item interface{}) []interface{}
- func ArrayRand(arr interface{}, num int) []interface{}
- func ArrayReverse(arr interface{}) []interface{}
- func ArrayReverseString(ss []string)
- func ArraySearchItem(arr interface{}, condition map[string]interface{}) (res interface{})
- func ArraySearchMutil(arr interface{}, condition map[string]interface{}) (res []interface{})
- func ArrayShuffle(arr interface{}) []interface{}
- func ArrayStringsRemove(ss []string, s string) []string
- func ArrayUnique(arr interface{}) map[interface{}]interface{}
- func ArrayValues(arr interface{}, filterZero bool) []interface{}
- func AtWho(text string, minLen ...int) []string
- func Average(nums ...interface{}) (res float64)
- func AverageFloat64(nums ...float64) (res float64)
- func AverageInt(nums ...int) (res float64)
- func Basename(path string) string
- func Before(n int, fn interface{}) func(args ...interface{}) []reflect.Value
- func Big5ToUtf8(s []byte) ([]byte, error)
- func BinToDec(str string) (int64, error)
- func BinToHex(str string) (string, error)
- func BoolToInt(val bool) int
- func Br2nl(str string) string
- func BuildQueryMap(result map[string]interface{}, keys []string, value interface{}) error
- func ByteFormat(size float64, decimal uint8, delimiter string) string
- func ByteToString(_byte []byte) string
- func ByteToStringFast(_byte []byte) string
- func CallFunc(f interface{}, args ...interface{}) (results []interface{}, err error)
- func CallMethod(t interface{}, method string, args ...interface{}) ([]interface{}, error)
- func CamelCaseToLowerCase(str string, connector rune) string
- func Ceil(value float64) float64
- func Chdir(dir string) error
- func Chmod(filename string, mode os.FileMode) bool
- func ChmodBatch(fpath string, filemode, dirmode os.FileMode) (res bool)
- func Chown(filename string, uid, gid int) bool
- func Chr(chr uint) string
- func ChunkBytes(bs []byte, size int) [][]byte
- func ChunkSplit(str string, chunklen uint, end string) string
- func ClearUrlPrefix(str string, prefix ...string) string
- func ClearUrlSuffix(str string, suffix ...string) string
- func ClientIp(req *http.Request) string
- func ClosestWord(word string, searchs []string) (string, int)
- func CompareEQ(lhs, rhs interface{}) bool
- func CompareGE(lhs, rhs interface{}) bool
- func CompareGT(lhs, rhs interface{}) bool
- func CompareLE(lhs, rhs interface{}) bool
- func CompareLT(lhs, rhs interface{}) bool
- func Compose(fnList ...func(...interface{}) interface{}) func(...interface{}) interface{}
- func CopyDir(source string, dest string, cover LkkFileCover) (int64, error)
- func CopyFile(source string, dest string, cover LkkFileCover) (int64, error)
- func CopyLink(source string, dest string) error
- func CopyStruct(dest interface{}, resources ...interface{}) interface{}
- func CountBase64Byte(str string) (res int)
- func CountLines(fpath string, buffLength int) (int, error)
- func CountWords(str string) (int, map[string]int)
- func CpuUsage() (user, idle, total uint64)
- func Crc32(str string) uint32
- func CtxGo(ctx context.Context, f func())
- func CutSlice(arr interface{}, offset, size int) []interface{}
- func DBC2SBC(s string) string
- func DateToTimeS(_date string, format string) int64
- func DayEnd(t time.Time) time.Time
- func DayStart(t time.Time) time.Time
- func Debounced(fn func(), duration time.Duration) func()
- func DecToBin(num int64) string
- func DecToHex(num int64) string
- func DecToOct(num int64) string
- func DecodeBase64(_string string) string
- func DecodeByte(data []byte, target interface{}) error
- func DecodeURL(_url string) (string, error)
- func DecodeUrlBase64(_string string) string
- func DelDir(dir string, delete bool) error
- func Delay(delay time.Duration, fn interface{}, args ...interface{})
- func DeleteInt16Slice(src []int16, indexes ...int) []int16
- func DeleteInt32Slice(src []int32, indexes ...int) []int32
- func DeleteInt64Slice(src []int64, indexes ...int) []int64
- func DeleteInt8Slice(src []int8, indexes ...int) []int8
- func DeleteIntSlice(src []int, indexes ...int) []int
- func DeleteSlice(slice interface{}, indexes ...int) interface{}
- func DeleteSliceE(slice interface{}, indexes ...int) (interface{}, error)
- func DeleteSliceElms(i interface{}, elms ...interface{}) interface{}
- func DeleteSliceElmsE(i interface{}, elms ...interface{}) (interface{}, error)
- func DeleteSliceItems(val interface{}, ids ...int) (res []interface{}, del int)
- func DeleteStrSlice(src []string, indexes ...int) []string
- func DeleteUint16Slice(src []int, indexes ...int) []uint16
- func DeleteUint32Slice(src []uint32, indexes ...int) []uint32
- func DeleteUint64Slice(src []uint64, indexes ...int) []uint64
- func DeleteUint8Slice(src []int8, indexes ...int) []uint8
- func DeleteUintSlice(src []int, indexes ...int) []uint
- func DetectEncoding(str string) (res string)
- func Dir(path string) string
- func DirSize(fpath string) int64
- func Dirname(fpath string) string
- func DiskUsage(path string) (used, free, total uint64)
- func Dstrpos(str string, arr []string, chkCase bool) (bool, string)
- func DumpPrint(vs ...interface{})
- func Empty(val interface{}) bool
- func EncodeBase64(_string string) string
- func EncodeByte(data interface{}) ([]byte, error)
- func EncodeURL(_url string) string
- func EncodeUrlBase64(_string string) string
- func EndsWith(str, sub string, ignoreCase bool) bool
- func EndsWiths(str string, subs []string, ignoreCase bool) (res bool)
- func Exec(command string) (retInt int, outStr, errStr []byte)
- func Exp(x float64) float64
- func Explode(str string, delimiters ...string) (res []string)
- func Expm1(x float64) float64
- func Ext(path string) string
- func ExtName(path string) string
- func FileGetBytes(filenameOrURL string, timeout ...time.Duration) ([]byte, error)
- func FileGetCSV(filenameOrURL string, timeout ...time.Duration) ([][]string, error)
- func FileGetContent(path string) (string, error)
- func FilePutContent(path string, content string, isAppend bool) error
- func FileSetBytes(filename string, data []byte) error
- func FileSetCSV(filename string, records [][]string) error
- func FileSize(fpath string) int64
- func FileTree(fpath string, ftype LkkFileTree, recursive bool, filters ...FileFilter) []string
- func FilterHTML(html string) string
- func FilterIframe(html string) string
- func FilterJS(html string) string
- func FilterStyle(html string) string
- func FilterToLower(html string) string
- func FilterXML(html string) string
- func FirstLetter(str string) string
- func FloatEqual(f1 float64, f2 float64, decimal ...uint8) (res bool)
- func FloatToString(val interface{}, decimal int) string
- func Floor(value float64) float64
- func ForceGC()
- func Format(t time.Time) string
- func FormatBy(t time.Time, layout string) string
- func FormatDir(fpath string) string
- func FormatPath(fpath string) string
- func FormatUnix(sec int64) string
- func FormatUnixBy(sec int64, layout string) string
- func FormatUrl(str string) string
- func GbkToUtf8(s []byte) ([]byte, error)
- func GenUUID() string
- func GeoDistance(lng1, lat1, lng2, lat2 float64) float64
- func Get(url string) string
- func GetCallDir() string
- func GetCallFile() string
- func GetCallLine() int
- func GetCallName(f interface{}, onlyFun bool) string
- func GetCallPackage(callFile ...string) string
- func GetCurrentPwd() string
- func GetDatesBetweenDay(startDate string, endDate string, format string) (day int64)
- func GetDomain(str string, isMain ...bool) string
- func GetEleIndexesSlice(slice interface{}, value interface{}) []int
- func GetEleIndexesSliceE(slice interface{}, value interface{}) ([]int, error)
- func GetEndian() binary.ByteOrder
- func GetEquationValue(str, name string) (res string)
- func GetFieldValue(arr interface{}, fieldName string) (res interface{}, err error)
- func GetFileMode(fpath string) (os.FileMode, error)
- func GetFileShaX(fpath string, x uint16) (string, error)
- func GetFuncNames(val interface{}) (res []string)
- func GetHostByIp(ipAddress string) (string, error)
- func GetIPs() (ips []string)
- func GetImageList(s string) []string
- func GetIntersectStrings(minLen int, str1, str2 string) (res []string)
- func GetIpByHostname(hostname string) (string, error)
- func GetIpsByDomain(domain string) ([]string, error)
- func GetLongestSameString(str1, str2 string) (res string)
- func GetMacAddrs() (macAddrs []string)
- func GetMethod(val interface{}, methodName string) interface{}
- func GetMime(fpath string, fast bool) string
- func GetModTime(fpath string) (res int64)
- func GetPidByPort(port int) (pid int)
- func GetProcessExecPath(pid int) string
- func GetRandomSliceElem(i interface{}) interface{}
- func GetTempDir() string
- func GetTimeDate(_format string) (date string)
- func GetUrlParam(_url string, _key string) (value string)
- func GetVariatePointerAddr(val interface{}) int64
- func GetVariateType(v interface{}) string
- func Getcwd() (string, error)
- func Getenv(varname string, defvalue ...string) string
- func Gettype(variable interface{}) string
- func Glob(pattern string, onlyNames bool) ([]string, error)
- func Go(f func())
- func GoMemory() uint64
- func Gravatar(email string, size uint16) string
- func HasChinese(str string) bool
- func HasEmoji(str string) bool
- func HasEnglish(str string) bool
- func HasFullWidth(str string) bool
- func HasHalfWidth(str string) bool
- func HasLetter(str string) bool
- func HasMethod(t interface{}, method string) bool
- func HasSpecialChar(str string) bool
- func HasWhitespace(str string) bool
- func HashidsDecrypt(salt string, minLength int, hash string) []int
- func HashidsEncrypt(salt string, minLength int, params []int) string
- func HexToBin(str string) (string, error)
- func HexToByte(str string) ([]byte, error)
- func HexToDec(str string) (int64, error)
- func HideCard(card string) string
- func HideMobile(mobile string) string
- func HideTrueName(name string) string
- func Home() (dir string, err error)
- func HomeDir() (string, error)
- func Hostname() (string, error)
- func HourEnd(t time.Time) time.Time
- func HourStart(t time.Time) time.Time
- func Html2Text(str string) string
- func Htmlentities(str string) string
- func HtmlentityDecode(str string) string
- func HttpBuildQuery(queryData url.Values) string
- func ImageDrawRGBA(img *image.RGBA, imgcode image.Image, x, y int)
- func ImageDrawRGBAOffSet(img *image.RGBA, imgcode image.Image, r image.Rectangle, x, y int)
- func ImageJPEG(ph string) (image.Image, error)
- func ImagePNG(ph string) (image.Image, error)
- func ImageRGBA(width, height int) *image.RGBA
- func Img2Base64(fpath string) string
- func Implode(delimiter string, arr interface{}) string
- func InArray(needle interface{}, haystack interface{}) bool
- func InInt64Slice(i int64, list []int64) bool
- func InIntSlice(i int, list []int) bool
- func InRange(value interface{}, left interface{}, right interface{}) bool
- func InRangeFloat32(value, left, right float32) bool
- func InRangeFloat64(value, left, right float64) bool
- func InRangeInt(value, left, right int) bool
- func InStringSlice(str string, list []string) bool
- func Index(str, sub string, ignoreCase bool) int
- func InsertInt16Slice(src []int, index int, value int16) []int16
- func InsertInt32Slice(src []int, index int, value int32) []int32
- func InsertInt64Slice(src []int, index int, value int64) []int64
- func InsertInt8Slice(src []int8, index int, value int8) []int8
- func InsertIntSlice(src []int, index, value int) []int
- func InsertSliceE(slice interface{}, index int, value interface{}) (interface{}, error)
- func InsertStrSlice(src []int, index int, value string) []string
- func InsertUint16Slice(src []int, index int, value uint16) []uint16
- func InsertUint32Slice(src []int, index int, value uint32) []uint32
- func InsertUint64Slice(src []int, index int, value uint64) []uint64
- func InsertUint8Slice(src []int8, index int, value uint8) []uint8
- func InsertUintSlice(src []int, index int, value uint) []uint
- func Int32ToInt64(_int int32) int64
- func Int64ToInt32(_int int64) int32
- func IntToString(val interface{}) string
- func InterfaceToFloat(val interface{}) (res float64)
- func InterfaceToInt(val interface{}) (res int)
- func InterfaceToString(_array interface{}) string
- func InvokeAttr(object interface{}, attrName string) interface{}
- func InvokeMethod(object interface{}, methodName string, args ...interface{})
- func Ip2Long(ipAddress string) uint32
- func IsASCII(str string) bool
- func IsAlphaNumeric(str string) bool
- func IsArray(variable interface{}) bool
- func IsBase64(str string) bool
- func IsBase64Image(str string) bool
- func IsBinary(s string) bool
- func IsBinaryFile(fpath string) bool
- func IsBlank(str string) bool
- func IsBool(variable interface{}) bool
- func IsChinese(str string) bool
- func IsChineseName(str string) bool
- func IsContains(i interface{}, target interface{}) bool
- func IsCredit(id string) byte
- func IsCreditNo(str string) (bool, string)
- func IsDNSName(str string) bool
- func IsDate2time(str string) (bool, int64)
- func IsDialAddr(str string) bool
- func IsDir(path string) bool
- func IsDouble(variable interface{}) bool
- func IsEmail(email string, validateHost bool) (bool, error)
- func IsEmpty(params interface{}) bool
- func IsEnglish(str string, letterCase LkkCaseSwitch) bool
- func IsEqualArray(arr1, arr2 interface{}) bool
- func IsEqualMap(arr1, arr2 interface{}) bool
- func IsEven(val int) bool
- func IsExist(fpath string) bool
- func IsFile(fpath string, ftype ...LkkFileType) (res bool)
- func IsFloat(variable interface{}) bool
- func IsGbk(s []byte) (res bool)
- func IsHex(str string) (res bool)
- func IsHexColor(str string) (bool, string)
- func IsHost(str string) bool
- func IsIP(str string) bool
- func IsIPv4(str string) bool
- func IsIPv6(str string) bool
- func IsImg(fpath string) bool
- func IsInt(variable interface{}) bool
- func IsInteger(variable interface{}) bool
- func IsInterface(val interface{}) bool
- func IsJSON(str string) bool
- func IsLetters(str string) bool
- func IsLink(fpath string) bool
- func IsLinux() bool
- func IsLittleEndian() bool
- func IsLong(variable interface{}) bool
- func IsLower(str string) bool
- func IsMACAddr(str string) bool
- func IsMac() bool
- func IsMap(val interface{}) bool
- func IsMd5(str string) bool
- func IsMobilecn(str string) bool
- func IsMultibyte(str string) bool
- func IsNan(val interface{}) bool
- func IsNatural(value float64) bool
- func IsNaturalRange(arr []int, strict bool) (res bool)
- func IsNegative(value float64) bool
- func IsNil(val interface{}) bool
- func IsNonNegative(value float64) bool
- func IsNonPositive(value float64) bool
- func IsNumeric(variable interface{}) bool
- func IsOdd(val int) bool
- func IsPhone(str string) bool
- func IsPointer(val interface{}, notNil bool) (res bool)
- func IsPortOpen(host string, port interface{}, protocols ...string) bool
- func IsPositive(value float64) bool
- func IsPrivateIp(str string) (bool, error)
- func IsProcessExists(pid int) (res bool)
- func IsPublicIP(str string) (bool, error)
- func IsRgbColor(str string) bool
- func IsRsaPublicKey(str string, keylen uint16) bool
- func IsSha1(str string) bool
- func IsSha256(str string) bool
- func IsSha512(str string) bool
- func IsSlice(val interface{}) bool
- func IsString(variable interface{}) bool
- func IsStruct(val interface{}) bool
- func IsTel(str string) bool
- func IsUpper(str string) bool
- func IsUrl(str string) bool
- func IsUrlExists(str string) bool
- func IsUtf8(s []byte) bool
- func IsWhitespaces(str string) bool
- func IsWhole(value float64) bool
- func IsWindows() bool
- func IsWord(str string) bool
- func IsZip(fpath string) bool
- func JoinInts(delimiter string, ints []int) (res string)
- func JoinSliceWithSep(slice interface{}, sep string) string
- func JoinSliceWithSepE(slice interface{}, sep string) (string, error)
- func JoinStrings(delimiter string, strs []string) (res string)
- func JsonDecode(_string string, _type interface{}) error
- func JsonEncode(v interface{}) string
- func JsonFindFromFile(fileName string, key string) (*gojsonq.Result, error)
- func JsonFindFromStr(jsonStr, key string) (*gojsonq.Result, error)
- func JsonFromFile(fileName string) *gojsonq.JSONQ
- func JsonFromStr(jsonStr string) *gojsonq.JSONQ
- func JsonGetFromFile(fileName string) (*gojsonq.Result, error)
- func JsonGetFromStr(jsonStr string) (*gojsonq.Result, error)
- func JsonInit() *gojsonq.JSONQ
- func Jsonp2Json(str string) (string, error)
- func KafkaConsumer(brokerList []string, topic string, f func(msg *KafkaMessage))
- func KafkaGroupConsumer(brokerList []string, groupId string, topic string, f func(msg *KafkaMessage))
- func KafkaProduct(brokerList []string, topic string, message string) error
- func LastIndex(str, sub string, ignoreCase bool) int
- func LcFirst(_string string) string
- func Lcfirst(str string) string
- func Lcwords(str string) string
- func LeftPad(s string, padStr string, overallLen int) string
- func LenArrayOrSlice(val interface{}, chkType uint8) int
- func Levenshtein(a, b string) int
- func LoadConfig(configPath string)
- func LocalIP() (string, error)
- func Log(x, y float64) float64
- func Long2Ip(properAddress uint32) string
- func Ltrim(str string, characterMask ...string) string
- func MapInterfaceToJson(_map map[string]interface{}) []byte
- func MapInterfaceToString(_map map[string]interface{}, _key string) string
- func MapString(vs []string, f func(string) string) []string
- func MatchEquations(str string) (res []string)
- func Max(nums ...interface{}) (res float64)
- func MaxFloat32Slice(sl []float32) float32
- func MaxFloat64(nums ...float64) (res float64)
- func MaxFloat64Slice(sl []float64) float64
- func MaxInt(nums ...int) (res int)
- func MaxInt16Slice(sl []int16) int16
- func MaxInt32Slice(sl []int32) int32
- func MaxInt64Slice(sl []int64) int64
- func MaxInt8Slice(sl []int8) int8
- func MaxIntSlice(sl []int) int
- func MaxSliceE(slice interface{}) (interface{}, error)
- func MaxUint16Slice(sl []uint16) uint16
- func MaxUint32Slice(sl []uint32) uint32
- func MaxUint64Slice(sl []uint64) uint64
- func MaxUint8Slice(sl []uint8) uint8
- func MaxUintSl(sl []uint) uint
- func MbStrlen(str string) int
- func MbSubstr(str string, start int, length ...int) string
- func Md5(str []byte) string
- func MemoryUsage(virtual bool) (used, free, total uint64)
- func MergeMap(ss ...interface{}) map[interface{}]interface{}
- func MergeSlice(filterZero bool, ss ...interface{}) []interface{}
- func MethodExists(val interface{}, methodName string) (bool, error)
- func Min(nums ...interface{}) (res float64)
- func MinFloat32Slice(sl []float32) float32
- func MinFloat64(nums ...float64) (res float64)
- func MinFloat64Slice(sl []float64) float64
- func MinInt(nums ...int) (res int)
- func MinInt16Slice(sl []int16) int16
- func MinInt32Slice(sl []int32) int32
- func MinInt64Slice(sl []int64) int64
- func MinInt8Slice(sl []int8) int8
- func MinIntSlice(sl []int) int
- func MinSliceE(slice interface{}) (interface{}, error)
- func MinUint16Slice(sl []uint16) uint16
- func MinUint32Slice(sl []uint32) uint32
- func MinUint64Slice(sl []uint64) uint64
- func MinUint8Slice(sl []uint8) uint8
- func MinUintSlice(sl []uint) uint
- func Mkdir(path string) error
- func MonthEnd(t time.Time) time.Time
- func MonthStart(t time.Time) time.Time
- func Move(src string, dst string) error
- func NearLogarithm(num, base int, left bool) int
- func NetHostname() string
- func NetIP() string
- func NewStrMapItf() map[string]interface{}
- func NewStrMapStr() map[string]string
- func Nl2br(str string) string
- func Now() string
- func NowAddDay(day int) time.Time
- func NowAddHour(hour int) time.Time
- func NowAddMinutes(minutes int) time.Time
- func NowAddSeconds(seconds int) time.Time
- func NowHourStart() time.Time
- func NowMilliUnix() int64
- func NowNanoUnix() int64
- func NowUnix() int64
- func NumSign(value float64) (res int8)
- func NumberFormat(number float64, decimal uint8, point, thousand string) string
- func NumericToFloat(val interface{}) (res float64, err error)
- func OctToDec(str string) (int64, error)
- func Ord(char string) rune
- func OutboundIP() (string, error)
- func ParseStr(encodedString string, result map[string]interface{}) error
- func ParseUrl(str string, component int16) (map[string]string, error)
- func PasswordSafeLevel(str string) (res uint8)
- func Pathinfo(fpath string, option int) map[string]string
- func Percent(val, total interface{}) float64
- func Pkcs7Padding(cipherText []byte, blockSize int, isZero bool) []byte
- func Pkcs7UnPadding(origData []byte, blockSize int) []byte
- func Post(url string, data interface{}, contentType string) string
- func Pow(x, y float64) float64
- func PrivateCIDR() []*net.IPNet
- func Pwd() string
- func Quotemeta(str string) string
- func Rand(min, max int) int
- func RandFloat64(min, max float64) float64
- func RandInt(min, max int) int
- func RandInt64(min, max int64) int64
- func RandRange(_min int64, _max int64) int64
- func RandString(_length int64) string
- func Random(length uint8, rtype LkkRandString) string
- func Range(start, end int) []int
- func RawQueryGetParam(rawquery, key string) (string, error)
- func RawQueryGetParams(rawquery, key string) ([]string, error)
- func RawURLAddParam(rawUrl, key, value string) string
- func RawURLAddParams(rawUrl string, params map[string]string) string
- func RawURLDelParam(rawUrl, key string) string
- func RawURLDelParams(rawUrl string, keys []string) string
- func RawURLGetAllParams(rawUrl string) (map[string][]string, error)
- func RawURLGetParam(rawUrl, key string) (string, error)
- func RawURLGetParams(rawUrl, key string) ([]string, error)
- func RawURLSetParam(rawUrl, key, value string) string
- func RawURLSetParams(rawUrl string, params map[string]string) string
- func RawUrlDecode(str string) (string, error)
- func RawUrlEncode(str string) string
- func RawUrlGetDomain(rawUrl string) string
- func RawUrlGetPort(rawUrl string) string
- func ReadFile(fpath string) ([]byte, error)
- func ReadFirstLine(fpath string) []byte
- func ReadInArray(fpath string) ([]string, error)
- func ReadLastLine(fpath string) []byte
- func RealNetIP() string
- func RealPath(fpath string) string
- func ReferDownload(url string, site string, localFile string) string
- func RegisterPool(p Pool) error
- func Remove(path string) error
- func RemoveAfter(str, after string, include, ignoreCase bool) string
- func RemoveBefore(str, before string, include, ignoreCase bool) string
- func RemoveEmoji(str string) string
- func RemoveSpace(str string, all bool) string
- func Rename(oldname, newname string) error
- func Retry(retryFunc RetryFunc, opts ...Option) error
- func ReverseInt16Slice(src []int16) []int16
- func ReverseInt32Slice(src []int32) []int32
- func ReverseInt64Slice(src []int64) []int64
- func ReverseInt8Slice(src []int8) []int8
- func ReverseIntSlice(src []int) []int
- func ReverseSliceE(slice interface{}) (interface{}, error)
- func ReverseStrSlice(src []string) []string
- func ReverseUint16Slice(src []uint16) []uint16
- func ReverseUint32Slice(src []uint32) []uint32
- func ReverseUint64Slice(src []uint64) []uint64
- func ReverseUint8Slice(src []uint8) []uint8
- func ReverseUintSlice(src []uint) []uint
- func RightPad(s string, padStr string, overallLen int) string
- func Round(value float64) float64
- func RoundPlus(value float64, precision uint8) float64
- func RoundedFixed(val float64, n int) float64
- func RsaPrivateDecrypt(decryptStr string, path string) (string, error)
- func RsaPublicEncrypt(encryptStr string, path string) (string, error)
- func Rtrim(str string, characterMask ...string) string
- func RunesToBytes(rs []rune) []byte
- func SBC2DBC(s string) string
- func SafeFileName(str string) string
- func Schedule(d time.Duration, fn interface{}, args ...interface{}) chan bool
- func Serialize(val interface{}) ([]byte, error)
- func ServiceStartime() int64
- func ServiceUptime() time.Duration
- func SetPanicHandler(f func(context.Context, interface{}))
- func SetPoolCap(cap int32)
- func Setenv(varname, data string) error
- func ShaX(str string, x uint16) string
- func ShaXByte(str []byte, x uint16) []byte
- func Shuffle(str string) string
- func SimilarText(str1, str2 string, len1, len2 int) int
- func Sleep(t int64)
- func SliceFill(val interface{}, num int) []interface{}
- func SlicePop(s *[]interface{}) interface{}
- func SlicePush(s *[]interface{}, elements ...interface{}) int
- func SliceShift(s *[]interface{}) interface{}
- func SliceUnshift(s *[]interface{}, elements ...interface{}) int
- func SplitNaturalNum(num, base int) []int
- func StartsWith(str, sub string, ignoreCase bool) bool
- func StartsWiths(str string, subs []string, ignoreCase bool) (res bool)
- func Stat(path string) (os.FileInfo, error)
- func Str2Timestamp(str string, format ...string) (int64, error)
- func Str2Timestruct(str string, format ...string) (time.Time, error)
- func StringFilterInput(_value string) string
- func StringFormatBigInt(mem uint64) string
- func StringHideValue(_string string, start int, end int, replaceValue string) string
- func StringReplace(text string, _old string, _new string) string
- func StringReplaceMulti(str string, fromTo ...string) string
- func StringReplaceRange(text string, _start int, _end int, _new string) string
- func StringReverse(str string) string
- func StringToBool(val string) (res bool)
- func StringToByte(_str string) []byte
- func StringToByteFast(_str string) (_byte []byte)
- func StringToFloat(_str string) float64
- func StringToInt(_str string) int64
- func StringToRunes(val string) []rune
- func StringToUTF8(cont, srcEncoding string) (str string, err error)
- func StripTags(str string) string
- func Stripos(haystack, needle string, offset int) int
- func Stripslashes(str string) string
- func Strlen(str string) int
- func Strpad(str string, fill string, max int, ptype LkkPadType) string
- func StrpadBoth(str string, fill string, max int) string
- func StrpadLeft(str string, fill string, max int) string
- func StrpadRight(str string, fill string, max int) string
- func Strpos(haystack, needle string, offset int) int
- func Strripos(haystack, needle string, offset int) int
- func Strrpos(haystack, needle string, offset int) int
- func StructToMap(obj interface{}) map[string]interface{}
- func Substr(str string, start int, length ...int) string
- func SubstrCount(str, substr string) int
- func SubstriCount(str, substr string) int
- func Sum(nums ...interface{}) (res float64)
- func SumFloat64(nums ...float64) float64
- func SumInt(nums ...int) int
- func SumSlice(slice interface{}) float64
- func SumSliceE(slice interface{}) (float64, error)
- func System(command string) (retInt int, outStr, errStr []byte)
- func TarGz(src string, dstTar string, ignorePatterns ...string) (bool, error)
- func TempDir(names ...string) string
- func TimeConvertToLayout(template string) string
- func ToCamelCase(str string) string
- func ToKebabCase(str string) string
- func ToSnakeCase(str string) string
- func ToString(val interface{}) string
- func TodayEnd() time.Time
- func TodayStart() time.Time
- func Touch(fpath string, size int64) bool
- func TriggerGC()
- func Trim(str string, characterMask ...string) string
- func TrimBOM(str []byte) []byte
- func TruncRound(val float64, n int) float64
- func UcFirst(_string string) string
- func Ucfirst(str string) string
- func Ucwords(str string) string
- func UnSerialize(data []byte, register ...interface{}) (val interface{}, err error)
- func UnTarGz(srcTar, dstDir string) (bool, error)
- func UnZip(srcZip, dstDir string) (bool, error)
- func Uniqid(prefix string) string
- func Unique64Ints(ints []int64) (res []int64)
- func UniqueFloat32Slice(src []float32) []float32
- func UniqueFloat64Slice(src []float64) []float64
- func UniqueInt16Slice(src []int16) []int16
- func UniqueInt32Slice(src []int32) []int32
- func UniqueInt64Slice(src []int64) []int64
- func UniqueInt8Slice(src []int8) []int8
- func UniqueIntSlice(src []int) []int
- func UniqueInts(ints []int) (res []int)
- func UniqueSliceE(slice interface{}) (interface{}, error)
- func UniqueStrSlice(src []string) []string
- func UniqueStrings(strs []string) (res []string)
- func UniqueUint16Slice(src []uint16) []uint16
- func UniqueUint32Slice(src []uint32) []uint32
- func UniqueUint64Slice(src []uint64) []uint64
- func UniqueUint8Slice(src []uint8) []uint8
- func UniqueUintSlice(src []uint) []uint
- func Unlink(fpath string) error
- func Unsetenv(varname string) error
- func UpdateInt16Slice(src []int, index int, value int16) []int16
- func UpdateInt32Slice(src []int, index int, value int32) []int32
- func UpdateInt64Slice(src []int, index int, value int64) []int64
- func UpdateInt8Slice(src []int8, index int, value int8) []int8
- func UpdateIntSlice(src []int, index, value int) []int
- func UpdateSliceE(slice interface{}, index int, value interface{}) (interface{}, error)
- func UpdateStrSlice(src []int, index int, value string) []string
- func UpdateUint16Slice(src []int, index int, value uint16) []uint16
- func UpdateUint32Slice(src []int, index int, value uint32) []uint32
- func UpdateUint64Slice(src []int, index int, value uint64) []uint64
- func UpdateUint8Slice(src []int8, index int, value uint8) []uint8
- func UpdateUintSlice(src []int, index int, value uint) []uint
- func Uptime() (uint64, error)
- func UrlDecode(str string) (string, error)
- func UrlEncode(str string) string
- func Usleep(t int64)
- func Utf8ToBig5(s []byte) ([]byte, error)
- func Utf8ToGbk(s []byte) ([]byte, error)
- func UuidV4() (string, error)
- func UuidV5(name, namespace []byte) (string, error)
- func ValueInterfaceToString(value interface{}) string
- func VerifyFunc(f interface{}, args ...interface{}) (vf reflect.Value, vargs []reflect.Value, err error)
- func VersionCompare(version1, version2, operator string) (bool, error)
- func WrapError(err error, args ...interface{}) (res error)
- func YearEnd(t time.Time) time.Time
- func YearStart(t time.Time) time.Time
- func ZeroPadding(cipherText []byte, blockSize int) []byte
- func ZeroUnPadding(origData []byte) []byte
- func Zip(dst string, fpaths ...string) (bool, error)
- type BiosInfo
- type BoardInfo
- type CMPRES
- type CallBack
- type Config
- func (c *Config) Get(keyname string) interface{}
- func (c *Config) GetBool(keyname string) bool
- func (c *Config) GetDuration(keyname string) time.Duration
- func (c *Config) GetFloat64(keyname string) float64
- func (c *Config) GetFloat64ByDefault(keyname string, value float64) float64
- func (c *Config) GetInt(keyname string) int
- func (c *Config) GetInt32(keyname string) int32
- func (c *Config) GetInt32ByDefault(keyname string, value int32) int32
- func (c *Config) GetInt64(keyname string) int64
- func (c *Config) GetInt64ByDefault(keyname string, value int64) int64
- func (c *Config) GetIntByDefault(keyname string, value int) int
- func (c *Config) GetString(keyname string) string
- func (c *Config) GetStringByDefault(keyname string, value string) string
- func (c *Config) GetStringMap(keyname string) map[string]interface{}
- func (c *Config) GetStringMapString(keyname string) map[string]string
- func (c *Config) GetStringSlice(keyname string) []string
- type CpuInfo
- type FileFilter
- type Fn
- type KafkaGroupMessage
- type KafkaMessage
- type LkkArrCompareType
- type LkkCaseSwitch
- type LkkFileCover
- type LkkFileTree
- type LkkFileType
- type LkkPKCSType
- type LkkPadType
- type LkkRandString
- type Option
- type Pool
- type PoolConfig
- type RetryConfig
- type RetryFunc
- type StringBuilder
- func (s *StringBuilder) Bool(value bool) *StringBuilder
- func (s *StringBuilder) Byte(value byte) *StringBuilder
- func (s *StringBuilder) Bytes() []byte
- func (s *StringBuilder) Float(value float64) *StringBuilder
- func (s *StringBuilder) Int(value int) *StringBuilder
- func (s *StringBuilder) Printf(format string, args ...interface{}) *StringBuilder
- func (s *StringBuilder) String() string
- func (s *StringBuilder) Uint(value uint) *StringBuilder
- func (s *StringBuilder) Write(strings ...string) *StringBuilder
- func (s *StringBuilder) WriteBytes(bytes []byte) *StringBuilder
- func (s *StringBuilder) WriteTo(writer io.Writer) (n int64, err error)
- type SyncBool
- type SyncFloat
- type SyncInt
- type SyncMap
- func (s *SyncMap) Add(key string, value interface{})
- func (s *SyncMap) AddBool(key string, value bool)
- func (s *SyncMap) AddFloat(key string, value float64)
- func (s *SyncMap) AddInt(key string, value int)
- func (s *SyncMap) AddString(key string, value string)
- func (s *SyncMap) Bool(key string) *SyncBool
- func (s *SyncMap) Delete(key string)
- func (s *SyncMap) Float(key string) *SyncFloat
- func (s *SyncMap) Get(key string) interface{}
- func (s *SyncMap) Has(key string) bool
- func (s *SyncMap) Int(key string) *SyncInt
- func (s *SyncMap) String(key string) *SyncString
- type SyncPoolMap
- type SyncString
- type SyncStringMap
- type SystemInfo
- type Watcher
Constants ¶
const ( // DefaultRetryTimes times of retry DefaultRetryTimes = 5 // DefaultRetryDuration time duration of two retries DefaultRetryDuration = time.Second * 3 )
const ( // Version 版本号 Version = "1.0.0" // KDelimiter 本库自定义分隔符 KDelimiter = "$@#KSYSK#@$" Unknown = "Unknown" //UINT_MAX 无符号整型uint最大值 UINT_MAX = ^uint(0) //UINT8_MAX 无符号整型uint8最大值, 255 UINT8_MAX = ^uint8(0) //UINT16_MAX 无符号整型uint16最大值, 65535 UINT16_MAX = ^uint16(0) //UINT32_MAX 无符号整型uint32最大值, 4294967295 UINT32_MAX = ^uint32(0) //UINT64_MAX 无符号整型uint64最大值, 18446744073709551615 UINT64_MAX = ^uint64(0) //INT_MAX 有符号整型int最大值 INT_MAX = int(^uint(0) >> 1) //INT_MIN 有符号整型int最小值 INT_MIN = ^INT_MAX //INT32_MAX 有符号整型int32最大值, 2147483647 INT32_MAX = int32(^uint32(0) >> 1) //INT32_MIN 有符号整型int32最小值, -2147483648 INT32_MIN = ^INT32_MAX //INT64_MAX 有符号整型int64最大值, 9223372036854775807 INT64_MAX = int64(^uint64(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 uint8 = 8 //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})$` //正则模式-等式 x = y PATTERN_EQUATION = `['"]?([\w\-]+)['"]?[\s]*=[\s]*['"]?(.*)['"]?` // 正则模式-emoji表情符 PATTERN_EMOJI = `` /* 21966-byte string literal not displayed */ )
const ( OneMinSec = 60 OneHourSec = 3600 OneDaySec = 86400 OneWeekSec = 7 * 86400 OneMin = time.Minute OneHour = time.Hour OneDay = 24 * time.Hour OneWeek = 7 * 24 * time.Hour )
const (
Separator = string(filepath.Separator)
)
Variables ¶
var ( // 已编译的正则 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) RegEquation = regexp.MustCompile(PATTERN_EQUATION) RegAscii = regexp.MustCompile(PATTERN_ASCII) )
公开变量
var (
// DefaultLayout template for format time
DefaultTimeLayout = "2006-01-02 15:04:05"
)
var (
ImageExtList = []string{"bmp", "jpg", "png", "tif", "gif", "pcx", "tga", "exif", "fpx", "svg", "psd", "cdr", "pcd", "dxf", "ufo", "eps", "ai", "raw", "wmf", "webp", "avif", "apng"}
)
私有变量
Functions ¶
func AddMinutes ¶
AddMinutes add some minutes time for given time
func AddNanoseconds ¶
AddNanoseconds add some seconds time for given time
func AddSeconds ¶
AddSeconds add some seconds time for given time
func AesEncrypt ¶
加密 aes_128_cbc
func ArrayChunk ¶
func ArrayChunk(arr interface{}, size int) [][]interface{}
ArrayChunk 将一个数组/切片分割成多个,size为每个子数组的长度.
func ArrayColumn ¶
func ArrayColumn(arr interface{}, columnKey string) []interface{}
ArrayColumn 返回数组(切片/字典/结构体)中元素指定的一列. arr的元素必须是字典; columnKey为元素的字段名; 该方法效率较低.
func ArrayDiff ¶
func 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 ArrayFlip ¶
func ArrayFlip(arr interface{}) map[interface{}]interface{}
ArrayFlip 交换数组(切片/字典)中的键和值.
func ArrayInterfaceToString ¶
func ArrayInterfaceToString(_array interface{}) string
ArrayInterfaceToString interface转string,准对一维数组[]string{}或[]int{}
func ArrayIntersect ¶
func 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 ArrayKeyExists ¶
func ArrayKeyExists(key interface{}, arr interface{}) bool
ArrayKeyExists 检查arr(数组/切片/字典/结构体)里是否有key指定的键名(索引/字段).
func ArrayKeys ¶
func ArrayKeys(arr interface{}) []interface{}
ArrayKeys 返回数组(切片/字典/结构体)中所有的键名;如果是结构体,只返回公开的字段.
func ArrayPad ¶
func ArrayPad(arr interface{}, size int, item interface{}) []interface{}
ArrayPad 以指定长度将一个值item填充进arr数组/切片. 若 size 为正,则填补到数组的右侧,如果为负则从左侧开始填补; 若 size 的绝对值小于或等于 arr 数组的长度则没有任何填补.
func ArrayRand ¶
func ArrayRand(arr interface{}, num int) []interface{}
ArrayRand 从数组(切片/字典)中随机取出num个元素.
func ArrayReverse ¶
func ArrayReverse(arr interface{}) []interface{}
ArrayReverse 返回单元顺序相反的数组(仅限数组和切片).
func ArrayReverseString ¶
func ArrayReverseString(ss []string)
Reverse string slice [site user info 0] -> [0 info user site]
func ArraySearchItem ¶
func ArraySearchItem(arr interface{}, condition map[string]interface{}) (res interface{})
ArraySearchItem 从数组(切片/字典)中搜索对应元素(单个). arr为要查找的数组,元素必须为字典/结构体;condition为条件字典.
func ArraySearchMutil ¶
func ArraySearchMutil(arr interface{}, condition map[string]interface{}) (res []interface{})
ArraySearchMutil 从数组(切片/字典)中搜索对应元素(多个). arr为要查找的数组,元素必须为字典/结构体;condition为条件字典.
func ArrayStringsRemove ¶
StringsRemove a value form a string slice
func ArrayUnique ¶
func ArrayUnique(arr interface{}) map[interface{}]interface{}
ArrayUnique 移除数组(切片/字典)中重复的值,返回字典,保留键名.
func ArrayValues ¶
func ArrayValues(arr interface{}, filterZero bool) []interface{}
arrayValues 返回arr(数组/切片/字典/结构体)中所有的值. filterZero 是否过滤零值元素(nil,false,0,”,[]),true时排除零值元素,false时保留零值元素.
func BuildQueryMap ¶
buildQueryMap 创建URL Query参数字典. result 为结果字典;keys 为键数组;value为键值.
func ByteFormat ¶
ByteFormat 格式化文件比特大小. size为文件大小,decimal为要保留的小数位数,delimiter为数字和单位间的分隔符.
func ByteToString ¶
func ByteToStringFast ¶
func CallFunc ¶
func CallFunc(f interface{}, args ...interface{}) (results []interface{}, err error)
CallFunc 动态调用函数.
func CallMethod ¶
CallMethod 调用对象的方法. 若执行成功,则结果是该方法的返回结果; 否则返回(nil, error).
func CamelCaseToLowerCase ¶
CamelCaseToLowerCase 驼峰转为小写.
func ChmodBatch ¶
ChmodBatch 批量改变路径权限模式(包括子目录和所属文件). filemode为文件权限模式,dirmode为目录权限模式.
func ChunkBytes ¶
ChunkBytes 将字节切片分割为多个小块.其中size为每块的长度.
func ChunkSplit ¶
ChunkSplit 将字符串分割成小块.str为要分割的字符,chunklen为分割的尺寸,end为行尾序列符号.
func ClearUrlPrefix ¶
ClearUrlPrefix 清除URL的前缀; str为URL字符串,prefix为前缀,默认"/".
func ClearUrlSuffix ¶
ClearUrlSuffix 清除URL的后缀; str为URL字符串,suffix为后缀,默认"/".
func ClosestWord ¶
ClosestWord 获取与原字符串相似度最高的字符串,以及它们的编辑距离. word为原字符串,searchs为待查找的字符串数组.
func Compose ¶
func Compose(fnList ...func(...interface{}) interface{}) func(...interface{}) interface{}
Compose compose the functions from right to left
func CopyDir ¶
func CopyDir(source string, dest string, cover LkkFileCover) (int64, error)
CopyDir 拷贝源目录到目标目录,cover为枚举(FILE_COVER_ALLOW、FILE_COVER_IGNORE、FILE_COVER_DENY).
func CopyFile ¶
func CopyFile(source string, dest string, cover LkkFileCover) (int64, error)
CopyFile 拷贝源文件到目标文件,cover为枚举(FILE_COVER_ALLOW、FILE_COVER_IGNORE、FILE_COVER_DENY).
func CopyStruct ¶
func CopyStruct(dest interface{}, resources ...interface{}) interface{}
CopyStruct 将resources的值拷贝到dest目标结构体; 要求dest必须是结构体指针,resources为多个源结构体;若resources存在多个相同字段的元素,结果以最后的为准; 只简单核对字段名,无错误处理,需开发自行检查dest和resources字段类型才可操作.
func CountBase64Byte ¶
CountBase64Byte 粗略统计base64字符串大小,字节.
func CountLines ¶
CountLines 统计文件行数.buffLength为缓冲长度,kb.
func CountWords ¶
CountWords 统计字符串中单词的使用情况. 返回结果:单词总数;和一个字典,包含每个单词的单独统计. 因为没有分词,对中文尚未很好支持.
func CpuUsage ¶
func CpuUsage() (user, idle, total uint64)
CpuUsage 获取CPU使用率(darwin系统必须使用cgo),单位jiffies(节拍数). user为用户态(用户进程)的运行时间, idle为空闲时间, total为累计时间.
func CutSlice ¶
func CutSlice(arr interface{}, offset, size int) []interface{}
CutSlice 裁剪切片,返回根据offset(起始位置)和size(数量)参数所指定的arr(数组/切片)中的一段切片.
func Debounced ¶
Debounced creates a debounced function that delays invoking fn until after wait duration have elapsed since the last time the debounced function was invoked.
func DecodeByte ¶
DecodeByte decode byte data to target object
func DecodeUrlBase64 ¶
DecodeUrlBase64 解密文件和url名安全型base64
func DeleteInt16Slice ¶
DeleteInt16Slice deletes int16 slice elements by indexes.
func DeleteInt32Slice ¶
DeleteInt32Slice deletes int32 slice elements by indexes.
func DeleteInt64Slice ¶
DeleteInt64Slice deletes int64 slice elements by indexes.
func DeleteInt8Slice ¶
DeleteInt8Slice deletes int8 slice elements by indexes.
func DeleteIntSlice ¶
DeleteIntSlice deletes int slice elements by indexes.
func DeleteSlice ¶
func DeleteSlice(slice interface{}, indexes ...int) interface{}
DeleteSlice deletes the specified index element from the slice. Note that the original slice will not be modified.
func DeleteSliceE ¶
DeleteSliceE deletes the specified index element from the slice with error. Note that the original slice will not be modified.
func DeleteSliceElms ¶
func DeleteSliceElms(i interface{}, elms ...interface{}) interface{}
DeleteSliceElms deletes the specified elements from the slice. Note that the original slice will not be modified.
func DeleteSliceElmsE ¶
func DeleteSliceElmsE(i interface{}, elms ...interface{}) (interface{}, error)
DeleteSliceElmsE deletes the specified elements from the slice. Note that the original slice will not be modified.
func DeleteSliceItems ¶
DeleteSliceItems 删除数组/切片的元素,返回一个新切片. ids为多个元素的索引(0~len(val)-1); del为删除元素的数量.
func DeleteStrSlice ¶
DeleteStrSlice deletes string slice elements by indexes.
func DeleteUint16Slice ¶
DeleteUint16Slice deletes uint16 slice elements by indexes.
func DeleteUint32Slice ¶
DeleteUint32Slice deletes uint32 slice elements by indexes.
func DeleteUint64Slice ¶
DeleteUint64Slice deletes uint64 slice elements by indexes.
func DeleteUint8Slice ¶
DeleteUint8Slice deletes uint8 slice elements by indexes.
func DeleteUintSlice ¶
DeleteUintSlice deletes uint slice elements by indexes.
func EncodeUrlBase64 ¶
EncodeUrlBase64 加密文件和url名安全型base64
func Exec ¶
Exec 执行一个外部命令. retInt为1时失败,为0时成功;outStr为执行命令的输出;errStr为错误输出. 命令如 "ls -a" "/bin/bash -c \"ls -a\""
func FileGetBytes ¶
func FileGetCSV ¶
func FileGetContent ¶
func FileSetBytes ¶
func FileSetCSV ¶
func FileTree ¶
func 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 FilterHTML ¶
func FilterToLower ¶
func FloatEqual ¶
FloatEqual 比较两个浮点数是否相等.decimal为小数精确位数,默认为 FLOAT_DECIMAL . 有效数值是长度(包括小数点)为17位之内的数值,最后一位会四舍五入.
func FloatToString ¶
FloatToString 将浮点数转换为字符串,decimal为小数位数.
func FormatUnixBy ¶
FormatUnixBy format time seconds use given layout
func GeoDistance ¶
GeoDistance 获取地理距离/米. 参数分别为两点的经度和纬度:lat:-90~90,lng:-180~180.
func GetCallName ¶
GetCallName 获取调用的方法名称;f为目标方法;onlyFun为true时仅返回方法,不包括包名.
func GetCallPackage ¶
GetCallPackage 获取调用方法或调用文件的包名.callFile为调用文件路径.
func GetCurrentPwd ¶
func GetCurrentPwd() string
GetCurrentPwd 获取当前程序运行所在的路径,注意和Getwd有所不同. 若当前执行的是链接文件,则会指向真实二进制程序的所在目录.
func GetDatesBetweenDay ¶
func GetDomain ¶
GetDomain 从URL字符串中获取域名. 可选参数isMain,默认为false,取完整域名;为true时,取主域名(如abc.test.com取test.com).
func GetEleIndexesSlice ¶
func GetEleIndexesSlice(slice interface{}, value interface{}) []int
func GetEleIndexesSliceE ¶
GetEleIndexesSliceE finds all indexes of the specified element in a slice.
func GetEquationValue ¶
GetEquationValue 获取等式str中变量name的值.
func GetFieldValue ¶
GetFieldValue 获取(字典/结构体的)字段值;fieldName为字段名,大小写敏感.
func GetFileShaX ¶
ShaX 计算文件的 shaX 散列值,x为1/256/512.
func GetImageList ¶
func GetIntersectStrings ¶
getIntersectStrings 获取两个字符串相同部分的切片. minLen为子串最小长度,为0则不限制.
func GetIpByHostname ¶
GetIpByHostname 返回主机名对应的 IPv4地址.
func GetIpsByDomain ¶
GetIpsByHost 获取互联网域名/主机名对应的 IPv4 地址列表.
func GetLongestSameString ¶
longestSameString 获取两个字符串最长相同的子串.
func GetMethod ¶
func GetMethod(val interface{}, methodName string) interface{}
GetMethod 获取val结构体的methodName方法. 注意:返回的方法中的第一个参数是接收者. 所以,调用返回的方法时,必须将接收者作为第一个参数传递.
func GetPidByPort ¶
GetPidByPort 根据端口号获取监听的进程PID. linux可能要求root权限; darwin依赖lsof; windows依赖netstat.
func GetProcessExecPath ¶
GetProcessExecPath 根据PID获取进程的执行路径.
func GetRandomSliceElem ¶
func GetRandomSliceElem(i interface{}) interface{}
GetRandomSliceElem get a random element from a slice or array. If the length of slice or array is zero it will panic.
func GetTimeDate ¶
func GetUrlParam ¶
GetUrlParam 获取url中的参数(非解码)
func GetVariatePointerAddr ¶
func GetVariatePointerAddr(val interface{}) int64
GetVariatePointerAddr 获取变量的指针地址.
func Go ¶ added in v1.0.2
func Go(f func())
Go is an alternative to the go keyword, which is able to recover panic.
gopool.Go(func(arg interface{}){ ... }(nil))
func HtmlentityDecode ¶
HtmlentityDecode 将HTML实体转换为它们对应的字符.
func HttpBuildQuery ¶
HttpBuildQuery 根据参数生成 URL-encode 之后的请求字符串.
func ImageDrawRGBAOffSet ¶
将图片绘制到图片
func InArray ¶
func InArray(needle interface{}, haystack interface{}) bool
InArray 元素needle是否在数组haystack(切片/字典)内.
func InRange ¶
func InRange(value interface{}, left interface{}, right interface{}) bool
InRange 数值是否在某个范围内,将自动转换类型再比较.
func InRangeFloat32 ¶
InRangeFloat32 数值是否在2个32位浮点数范围内.
func InRangeFloat64 ¶
InRangeFloat64 数值是否在2个64位浮点数范围内.
func InsertIntSlice ¶
func InsertSliceE ¶
InsertSliceE inserts a element to slice in the specified index. Note that the original slice will not be modified.
func Int32ToInt64 ¶
func Int64ToInt32 ¶
func InterfaceToFloat ¶
func InterfaceToFloat(val interface{}) (res float64)
InterfaceToFloat 强制将变量转换为浮点型. 数值类型将转为浮点型; 字符串将使用str2Float64; 布尔型的true为1.0,false为0; 数组、切片、字典、通道类型将取它们的长度; 指针、结构体类型为1.0,其他为0.
func InterfaceToInt ¶
func InterfaceToInt(val interface{}) (res int)
InterfaceToInt 强制将变量转换为整型. 数值类型将转为整型; 字符串将使用str2Int; 布尔型的true为1,false为0; 数组、切片、字典、通道类型将取它们的长度; 指针、结构体类型为1,其他为0.
func InterfaceToString ¶
func InterfaceToString(_array interface{}) string
func InvokeAttr ¶
func InvokeAttr(object interface{}, attrName string) interface{}
func InvokeMethod ¶
func InvokeMethod(object interface{}, methodName string, args ...interface{})
func IsContains ¶
func IsContains(i interface{}, target interface{}) bool
IsContains checks whether slice or array contains the target element. Note that if the target element is a numeric literal, please specify its type explicitly, otherwise it defaults to int. For example you might call like IsContains([]int32{1,2,3}, int32(1)).
func IsCreditNo ¶
IsCreditNo 检查是否(15或18位)身份证号码,并返回经校验的号码.
func IsDate2time ¶
func IsDialAddr ¶
IsDialAddr 是否网络拨号地址(形如127.0.0.1:80),用于net.Dial()检查.
func IsEnglish ¶
func IsEnglish(str string, letterCase LkkCaseSwitch) bool
IsEnglish 字符串是否纯英文.letterCase是否检查大小写,枚举值(CASE_NONE,CASE_LOWER,CASE_UPPER).
func IsEqualArray ¶
func IsEqualArray(arr1, arr2 interface{}) bool
IsEqualArray 两个数组/切片是否相同(不管元素顺序),且不会检查元素类型; arr1, arr2 是要比较的数组/切片.
func IsEqualMap ¶
func IsEqualMap(arr1, arr2 interface{}) bool
IsEqualMap 两个字典是否相同(不管键顺序),且不会严格检查元素类型; arr1, arr2 是要比较的字典.
func IsFile ¶
func 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 IsNaturalRange ¶
IsNaturalRange 是否连续的自然数数组/切片,如[0,1,2,3...],其中不能有间断. strict为是否严格检查元素的顺序.
func IsPortOpen ¶
IsPortOpen 检查主机端口是否开放. host为主机名;port为(整型/字符串)端口号;protocols为协议名称,可选,默认tcp.
func IsRsaPublicKey ¶
IsRsaPublicKey 检查字符串是否RSA的公钥,keylen为密钥长度.
func JoinSliceWithSep ¶
JoinSliceWithSep joins all elements in slice with a separator
func JoinSliceWithSepE ¶
JoinSliceWithSepE joins all elements in slice or array with separator and return an error if occurred.
func JoinStrings ¶
JoinStrings 使用分隔符delimiter连接字符串切片strs.效率比Implode高.
func JsonEncode ¶
func JsonEncode(v interface{}) string
func JsonFromFile ¶
func JsonFromStr ¶
func Jsonp2Json ¶
Jsonp2Json 将jsonp转为json串. Example: forbar({a:"1",b:2}) to {"a":"1","b":2}
func KafkaConsumer ¶
func KafkaConsumer(brokerList []string, topic string, f func(msg *KafkaMessage))
func KafkaGroupConsumer ¶
func KafkaGroupConsumer(brokerList []string, groupId string, topic string, f func(msg *KafkaMessage))
func LenArrayOrSlice ¶
lenArrayOrSlice 获取数组/切片的长度. chkType为检查类型,枚举值有(1仅数组,2仅切片,3数组或切片);结果为-1表示变量不是数组或切片,>=0表示合法长度.
func Levenshtein ¶
Levenshtein 计算两个字符串之间的编辑距离,返回值越小字符串越相似. 注意字符串最大长度为255.
func LoadConfig ¶
func LoadConfig(configPath string)
加载配置,默认文件是app.toml 如果配置文件是app.toml,配置项是key,则可以直接获取key值 如果配置文件是other.toml,配置项是key,则通过other.key获取配置项 配置项一般加引号
func MapInterfaceToJson ¶
func MapInterfaceToString ¶
MapInterfaceToString interface转string,针对map[string]interface{}的某个键
func MaxFloat32Slice ¶
func MaxFloat64Slice ¶
func MaxInt16Slice ¶
func MaxInt32Slice ¶
func MaxInt64Slice ¶
func MaxInt8Slice ¶
func MaxIntSlice ¶
func MaxSliceE ¶
func MaxSliceE(slice interface{}) (interface{}, error)
MaxSliceE returns the largest element of the slice and an error if occurred. If slice length is zero return the zero value of the element type.
func MaxUint16Slice ¶
func MaxUint32Slice ¶
func MaxUint64Slice ¶
func MaxUint8Slice ¶
func MbSubstr ¶
MbSubstr 返回(宽字符)字符串str的子串. start 为起始位置.若值是负数,返回的结果将从 str 结尾处向前数第 abs(start) 个字符开始. length 为截取的长度.若值时负数, str 末尾处的 abs(length) 个字符将会被省略. start/length的绝对值必须<=原字符串长度.
func MemoryUsage ¶
MemoryUsage 获取内存使用率,单位字节. 参数 virtual(仅支持linux),是否取虚拟内存. used为已用, free为空闲, total为总数.
func MergeMap ¶
func MergeMap(ss ...interface{}) map[interface{}]interface{}
MergeMap 合并字典,相同的键名时,后面的值将覆盖前一个值. ss是元素为字典的切片.
func MergeSlice ¶
func MergeSlice(filterZero bool, ss ...interface{}) []interface{}
MergeSlice 合并一个或多个数组/切片. filterZero 是否过滤零值元素(nil,false,0,”,[]),true时排除零值元素,false时保留零值元素. ss是元素为数组/切片的切片.
func MethodExists ¶
MethodExists 检查val结构体中是否存在methodName方法.
func MinFloat32Slice ¶
func MinFloat64Slice ¶
func MinInt16Slice ¶
func MinInt32Slice ¶
func MinInt64Slice ¶
func MinInt8Slice ¶
func MinIntSlice ¶
func MinSliceE ¶
func MinSliceE(slice interface{}) (interface{}, error)
MinSliceE returns the smallest element of the slice and an error if occurred. If slice length is zero return the zero value of the element type.
func MinUint16Slice ¶
func MinUint32Slice ¶
func MinUint64Slice ¶
func MinUint8Slice ¶
func MinUintSlice ¶
func NearLogarithm ¶
NearLogarithm 求以 base 为底 num 的对数临近值. num为自然数,base为正整数,left是否向左取整.
func NetHostname ¶
func NetHostname() string
func NetIP ¶
func NetIP() string
NetIP returns the primary IP address of the system or an empty string.
func NowAddMinutes ¶
NowAddMinutes add some minutes time from now
func NowAddSeconds ¶
NowAddSeconds add some seconds time from now
func NumberFormat ¶
NumberFormat 以千位分隔符方式格式化一个数字. decimal为要保留的小数位数,point为小数点显示的字符,thousand为千位分隔符显示的字符. 有效数值是长度(包括小数点)为17位之内的数值,最后一位会四舍五入.
func NumericToFloat ¶
numeric2Float 将数值转换为float64.
func ParseUrl ¶
ParseUrl 解析URL,返回其组成部分. component为需要返回的组成; -1: all; 1: scheme; 2: host; 4: port; 8: user; 16: pass; 32: path; 64: query; 128: fragment .
func PasswordSafeLevel ¶
PasswordSafeLevel 检查密码安全等级;为0 极弱,为1 弱,为2 一般,为3 很好,为4 极佳.
func Pathinfo ¶
Pathinfo 获取文件路径的信息. option为要返回的信息,枚举值如下: -1: all; 1: dirname; 2: basename; 4: extension; 8: filename; 若要查看某几项,则为它们之间的和.
func Pkcs7Padding ¶
Pkcs7Padding PKCS7填充. cipherText为密文;blockSize为分组长度;isZero是否零填充.
func Pkcs7UnPadding ¶
Pkcs7UnPadding PKCS7拆解. origData为源数据;blockSize为分组长度.
func Post ¶
发送POST请求 url: 请求地址 data: POST请求提交的数据 contentType: 请求体格式,如:application/json content: 请求放回的内容
func RandFloat64 ¶
RandFloat64 生成一个min~max范围内的随机float64浮点数.
func Random ¶
func 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 RawQueryGetParam ¶
RawQueryGetParam get the specified key parameter from query string rawquery is encoded query values without '?'. key is parameter name e.g. if query is "a=dog&b=tiger" and key is "a" will return dog
func RawQueryGetParams ¶
RawQueryGetParams get the specified key parameters from query string rawquery is encoded query values without '?'. key is parameter name e.g. if query is "a=dog&a=cat&b=tiger" and key is "a" will return [dog cat]
func RawURLAddParam ¶
if rawUrl=http://www.google.com:8080/news/index.asp?boardID=520&page=1&page=2#name and key=page value=3 will get http://www.google.com:8080/news/index.asp?boardID=520&page=1&page=2&page=3#name
func RawURLDelParam ¶
if rawUrl=http://www.google.com:8080/news/index.asp?boardID=520&page=1&page=2#name and key=page will get http://www.google.com:8080/news/index.asp?boardID=520#name
func RawURLDelParams ¶
func RawURLGetAllParams ¶
if rawUrl=http://www.google.com:8080/news/index.asp?boardID=520&page=1&page=2#name will get map[boardID:[520] page:[1 2]]
func RawURLGetParam ¶
if rawUrl=http://www.google.com:8080/news/index.asp?boardID=520&page=1&page=2#name and key="page" will get "1"
func RawURLGetParams ¶
if rawUrl=http://www.google.com:8080/news/index.asp?boardID=520&page=1&page=2#name and key=page will get [1 2]
func RawURLSetParam ¶
if rawUrl=http://www.google.com:8080/news/index.asp?boardID=520&page=1&page=2#name and key=page value=3 will get http://www.google.com:8080/news/index.asp?boardID=520&page=3#name
func RawUrlGetDomain ¶
if rawUrl=http://www.google.com:8080/news/index.asp?boardID=520&page=1&page=2#name will get www.google.com
func RawUrlGetPort ¶
if rawUrl=http://www.google.com:8080/news/index.asp?boardID=520&page=1&page=2#name will get 8080
func ReadInArray ¶
ReadInArray 把整个文件读入一个数组中,每行作为一个元素.
func RealNetIP ¶
func RealNetIP() string
RealNetIP returns the real local IP of the system or an empty string.
func RegisterPool ¶ added in v1.0.2
RegisterPool registers a new pool to the global map. GetPool can be used to get the registered pool by name. returns error if the same name is registered.
func RemoveAfter ¶
RemoveAfter 移除after之后的字符串; include为是否移除包括after本身; ignoreCase为是否忽略大小写.
func RemoveBefore ¶
RemoveBefore 移除before之前的字符串; include为是否移除包括before本身; ignoreCase为是否忽略大小写.
func RemoveSpace ¶
RemoveSpace 移除字符串中的空白字符. all为true时移除全部空白,为false时只替换连续的空白字符为一个空格.
func Retry ¶
Retry executes the retryFunc repeatedly until it was successful or canceled by the context The default times of retries is 5 and the default duration between retries is 3 seconds
func ReverseInt16Slice ¶
func ReverseInt32Slice ¶
func ReverseInt64Slice ¶
func ReverseInt8Slice ¶
func ReverseIntSlice ¶
func ReverseSliceE ¶
func ReverseSliceE(slice interface{}) (interface{}, error)
ReverseSliceE reverses the specified slice without modifying the original slice.
func ReverseStrSlice ¶
func ReverseUint16Slice ¶
func ReverseUint32Slice ¶
func ReverseUint64Slice ¶
func ReverseUint8Slice ¶
func ReverseUintSlice ¶
func RsaPrivateDecrypt ¶
私钥解密
func SetPanicHandler ¶ added in v1.0.2
SetPanicHandler sets the panic handler for the global pool.
func SetPoolCap ¶ added in v1.0.2
func SetPoolCap(cap int32)
SetCap is not recommended to be called, this func changes the global pool's capacity which will affect other callers.
func SimilarText ¶
SimilarText 计算两个字符串的相似度;返回在两个字符串中匹配字符的数目,以及相似程度百分数.
func SliceFill ¶
func SliceFill(val interface{}, num int) []interface{}
SliceFill 用给定的值val填充切片,num为插入元素的数量.
func SlicePush ¶
func SlicePush(s *[]interface{}, elements ...interface{}) int
SlicePush 将一个或多个元素压入切片的末尾(入栈),返回处理之后切片的元素个数.
func SliceUnshift ¶
func SliceUnshift(s *[]interface{}, elements ...interface{}) int
SliceUnshift 在切片开头插入一个或多个元素,返回处理之后切片的元素个数.
func SplitNaturalNum ¶
SplitNaturalNum 将自然数 num 按底数 base 进行拆解.
func StartsWiths ¶
StartsWiths 字符串str是否以subs其中之一为开头.
func Str2Timestamp ¶
Str2Timestamp 将字符串转换为时间戳,秒. str 为要转换的字符串; format 为该字符串的格式,默认为"2006-01-02 15:04:05" .
func Str2Timestruct ¶
Str2Timestruct 将字符串转换为时间结构. str 为要转换的字符串; format 为该字符串的格式,默认为"2006-01-02 15:04:05" .
func StringFilterInput ¶
StringFilterInput 过滤Input输入的值 转义%、"、'、(、)、!、/、^、*、.、
func StringFormatBigInt ¶
func StringHideValue ¶
StringHideValue 隐藏/替换字符串中的某些字符 如隐藏手机号:185*******6,调用Common.HideStringValue("18511111111", 3, 10, "*")
func StringReplaceMulti ¶
func StringReplaceRange ¶
func StringToBool ¶
str2Bool 将字符串转换为布尔值. 1, t, T, TRUE, true, True 等字符串为真; 0, f, F, FALSE, false, False 等字符串为假.
func StringToByte ¶
func StringToByteFast ¶
func StringToUTF8 ¶
StringToUTF8 将指定字符编码的字符串转为utf8
func Stripos ¶
Stripos 查找字符串首次出现的位置(不区分大小写),找不到时返回-1. haystack在该字符串中进行查找,needle要查找的字符串; offset起始位置,为负数时时,搜索会从字符串结尾指定字符数开始.
func Strpad ¶
func Strpad(str string, fill string, max int, ptype LkkPadType) string
Strpad 使用fill填充str字符串到指定长度max. ptype为填充类型,枚举值(PAD_LEFT,PAD_RIGHT,PAD_BOTH).
func StrpadBoth ¶
StrpadBoth 字符串两侧填充,请参考Strpad.
func StrpadLeft ¶
StrpadLeft 字符串左侧填充,请参考Strpad.
func StrpadRight ¶
StrpadRight 字符串右侧填充,请参考Strpad.
func Strpos ¶
Strpos 查找字符串首次出现的位置,找不到时返回-1. haystack在该字符串中进行查找,needle要查找的字符串; offset起始位置,为负数时时,搜索会从字符串结尾指定字符数开始.
func Substr ¶
Substr 截取字符串str的子串. start 为起始位置.若值是负数,返回的结果将从 str 结尾处向前数第 abs(start) 个字符开始. length 为截取的长度.若值时负数, str 末尾处的 abs(length) 个字符将会被省略. start/length的绝对值必须<=原字符串长度.
func SubstrCount ¶
SubstrCount 计算子串substr在字符串str中出现的次数,区分大小写.
func SubstriCount ¶
SubstriCount 计算子串substr在字符串str中出现的次数,忽略大小写.
func SumSlice ¶
func SumSlice(slice interface{}) float64
SumSlice calculates the sum of slice elements
func TimeConvertToLayout ¶
ToLayout convert date template to go time layout
Template Vars:
Y,y - year Y - year 2006 y - year 06 M,m - month 01 D,d - day 02 H,h - hour 15 I,i - minute 04 S,s - second 05
func UnSerialize ¶
UnSerialize 对字符串进行反序列化. 其中register注册对象,其类型必须和Serialize的一致.
func UniqueFloat32Slice ¶
func UniqueFloat64Slice ¶
func UniqueInt16Slice ¶
func UniqueInt32Slice ¶
func UniqueInt64Slice ¶
func UniqueInt8Slice ¶
func UniqueIntSlice ¶
func UniqueSliceE ¶
func UniqueSliceE(slice interface{}) (interface{}, error)
UniqueSliceE deletes repeated elements in a slice with error. Note that the original slice will not be modified.
func UniqueStrSlice ¶
func UniqueUint16Slice ¶
func UniqueUint32Slice ¶
func UniqueUint64Slice ¶
func UniqueUint8Slice ¶
func UniqueUintSlice ¶
func UpdateIntSlice ¶
func UpdateSliceE ¶
UpdateSliceE modifies the specified index element of slice. Note that the original slice will not be modified.
func UuidV5 ¶
UuidV5 根据提供的字符,使用sha1生成36位哈希值(Version5,RFC4122); name为要计算散列值的字符,可以为nil; namespace为命名空间,长度必须为16.
func ValueInterfaceToString ¶
func ValueInterfaceToString(value interface{}) string
ValueInterfaceToString interface转string,非map[string]interface{}
func VerifyFunc ¶
func VerifyFunc(f interface{}, args ...interface{}) (vf reflect.Value, vargs []reflect.Value, err error)
VerifyFunc 验证是否函数,并且参数个数、类型是否正确. 返回有效的函数、有效的参数.
func VersionCompare ¶
VersionCompare 对比两个版本号字符串. operator允许的操作符有: <, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <>, ne . 特定的版本字符串,将会用以下顺序处理: 无 < dev < alpha = a < beta = b < RC = rc < # < pl = p < ga < release = r 用法: VersionCompare("1.2.3-alpha", "1.2.3RC7", '>=') ; VersionCompare("1.2.3-beta", "1.2.3pl", 'lt') ; VersionCompare("1.1_dev", "1.2any", 'eq') .
func ZeroPadding ¶
zeroPadding PKCS7使用0填充.
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 Config ¶
type Config struct {
// contains filtered or unexported fields
}
func (*Config) GetFloat64ByDefault ¶
func (*Config) GetInt32ByDefault ¶
func (*Config) GetInt64ByDefault ¶
func (*Config) GetStringByDefault ¶
func (*Config) GetStringMap ¶
GetStringMap
func (*Config) GetStringMapString ¶
GetStringMapString
func (*Config) GetStringSlice ¶
GetStringSlice
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 Fn ¶
type Fn func(...interface{}) interface{}
Fn is for curry function which is func(...interface{}) interface{}
type KafkaGroupMessage ¶
type KafkaGroupMessage struct {
// contains filtered or unexported fields
}
func (KafkaGroupMessage) Cleanup ¶
func (KafkaGroupMessage) Cleanup(_ sarama.ConsumerGroupSession) error
func (KafkaGroupMessage) ConsumeClaim ¶
func (msg KafkaGroupMessage) ConsumeClaim(sess sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error
func (KafkaGroupMessage) Setup ¶
func (KafkaGroupMessage) Setup(_ sarama.ConsumerGroupSession) error
type KafkaMessage ¶
type KafkaMessage struct {
*sarama.ConsumerMessage
}
type Option ¶
type Option func(*RetryConfig)
Option is for adding retry config
func RetryDuration ¶
RetryDuration set duration of retries
type Pool ¶ added in v1.0.2
type Pool interface { // Name returns the corresponding pool name. Name() string // SetCap sets the goroutine capacity of the pool. SetCap(cap int32) // Go executes f. Go(f func()) // CtxGo executes f and accepts the context. CtxGo(ctx context.Context, f func()) // SetPanicHandler sets the panic handler. SetPanicHandler(f func(context.Context, interface{})) }
type PoolConfig ¶ added in v1.0.2
type PoolConfig struct { // threshold for scale. // new goroutine is created if len(task chan) > ScaleThreshold. // defaults to defaultScalaThreshold. ScaleThreshold int32 }
GoConfig is used to config pool.
func NewPoolConfig ¶ added in v1.0.2
func NewPoolConfig() *PoolConfig
NewGoConfig creates a default GoConfig.
type RetryConfig ¶
type RetryConfig struct {
// contains filtered or unexported fields
}
RetryConfig is config for retry
type StringBuilder ¶
type StringBuilder struct {
// contains filtered or unexported fields
}
func (*StringBuilder) Bool ¶
func (s *StringBuilder) Bool(value bool) *StringBuilder
func (*StringBuilder) Byte ¶
func (s *StringBuilder) Byte(value byte) *StringBuilder
func (*StringBuilder) Bytes ¶
func (s *StringBuilder) Bytes() []byte
func (*StringBuilder) Float ¶
func (s *StringBuilder) Float(value float64) *StringBuilder
func (*StringBuilder) Int ¶
func (s *StringBuilder) Int(value int) *StringBuilder
func (*StringBuilder) Printf ¶
func (s *StringBuilder) Printf(format string, args ...interface{}) *StringBuilder
func (*StringBuilder) String ¶
func (s *StringBuilder) String() string
func (*StringBuilder) Uint ¶
func (s *StringBuilder) Uint(value uint) *StringBuilder
func (*StringBuilder) Write ¶
func (s *StringBuilder) Write(strings ...string) *StringBuilder
func (*StringBuilder) WriteBytes ¶
func (s *StringBuilder) WriteBytes(bytes []byte) *StringBuilder
type SyncBool ¶
type SyncBool struct {
// contains filtered or unexported fields
}
func NewSyncBool ¶
type SyncFloat ¶
type SyncFloat struct {
// contains filtered or unexported fields
}
func NewSyncFloat ¶
type SyncMap ¶
type SyncMap struct {
// contains filtered or unexported fields
}
func NewSyncMap ¶
func NewSyncMap() *SyncMap
func (*SyncMap) String ¶
func (s *SyncMap) String(key string) *SyncString
type SyncPoolMap ¶
type SyncPoolMap struct {
// contains filtered or unexported fields
}
func NewSyncPoolMap ¶
func NewSyncPoolMap() *SyncPoolMap
func (*SyncPoolMap) Delete ¶
func (s *SyncPoolMap) Delete(key string)
func (*SyncPoolMap) GetOrAddNew ¶
func (s *SyncPoolMap) GetOrAddNew(key string, newFunc func() interface{}) *sync.Pool
func (*SyncPoolMap) Has ¶
func (s *SyncPoolMap) Has(key string) bool
type SyncString ¶
type SyncString struct {
// contains filtered or unexported fields
}
func NewSyncString ¶
func NewSyncString(value string) *SyncString
func (*SyncString) Append ¶
func (s *SyncString) Append(value string) string
func (*SyncString) Get ¶
func (s *SyncString) Get() string
func (*SyncString) Set ¶
func (s *SyncString) Set(value string)
func (*SyncString) Swap ¶
func (s *SyncString) Swap(value string) string
type SyncStringMap ¶
type SyncStringMap struct {
// contains filtered or unexported fields
}
func NewSyncStringMap ¶
func NewSyncStringMap() *SyncStringMap
func (*SyncStringMap) Add ¶
func (s *SyncStringMap) Add(key string, value string)
func (*SyncStringMap) Delete ¶
func (s *SyncStringMap) Delete(key string)
func (*SyncStringMap) Get ¶
func (s *SyncStringMap) Get(key string) string
func (*SyncStringMap) Has ¶
func (s *SyncStringMap) Has(key string) bool
type SystemInfo ¶
type SystemInfo struct { ServerName string `json:"server_name"` //服务器名称 SystemArch string `json:"system_arch"` //系统架构 SystemOs string `json:"system_os"` //操作系统名称 Runtime uint64 `json:"run_time"` //服务运行时间,纳秒 Uptime uint64 `json:"up_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 系统信息
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher is used for record code excution time
func (*Watcher) GetElapsedTime ¶
GetElapsedTime get excute elapsed time.