Documentation ¶
Index ¶
- Constants
- Variables
- func AbPathByCaller() string
- func AnyToArr(data interface{}) []interface{}
- func AnyToFloat64(data interface{}) float64
- func AnyToInt(data interface{}) int
- func AnyToInt64(data interface{}) int64
- func AnyToJson(data interface{}) (string, error)
- func AnyToJsonB(data interface{}) ([]byte, error)
- func AnyToMap(data interface{}) map[string]interface{}
- func AnyToString(i interface{}) string
- func AnyToStrings(data interface{}) []string
- func BIG5To(dstCharset string, src string) (dst string, err error)
- func Base64Decode(str string) (string, error)
- func Base64Encode(str string) string
- func Base64UrlDecode(str string) (string, error)
- func Base64UrlEncode(str string) string
- func BeginDayUnix() int64
- func BitToByte(b []uint8) []byte
- func BoolToByte(b bool) []byte
- func ByteToBinaryString(data byte) (str string)
- func ByteToBit(b []byte) []uint8
- func ByteToBool(b []byte) bool
- func ByteToFloat32(b []byte) float32
- func ByteToFloat64(b []byte) float64
- func ByteToGBK(strBuf []byte) []byte
- func ByteToInt(b []byte) int
- func ByteToInt64(b []byte) int64
- func ByteToStr(b []byte) string
- func CleaningStr(str string) string
- func CompressDirZip(src, outFile string) error
- func CompressFiles(files []string, dest string) error
- func ConvertByte2String(byte []byte, charset Charset) string
- func ConvertGBKToStr(gbkStr string) string
- func ConvertStrToGBK(str string) string
- func Date2Timestamp(date string) int64
- func DayAgo(i int) int64
- func DayAgoDate(i int) string
- func DayAgoDateYMD(i int) string
- func DayDiff(beginDay string, endDay string) int
- func DeCompressTAR(tarFile, dest string) error
- func DeCompressZIP(zipFile, dest string) error
- func Deadline(timestamp int64) string
- func DecodeByte(b []byte) (interface{}, error)
- func DecompressionZipFile(src, dest string) error
- func DeepCopy(dst, src interface{}) error
- func DeepEqual(a, b interface{}) bool
- func EncodeByte(v interface{}) []byte
- func EndDayUnix() int64
- func Exists(path string) bool
- func FileExists(name string) bool
- func FileMd5(path string) (string, error)
- func FileMd5sum(fileName string) string
- func Float32ToByte(f float32) []byte
- func Float32ToUint32(f float32) uint32
- func Float64ToByte(f float64) []byte
- func Float64ToUint64(f float64) uint64
- func GB18030To(dstCharset string, src string) (dst string, err error)
- func GB2312To(dstCharset string, src string) (dst string, err error)
- func GDKTo(dstCharset string, src string) (dst string, err error)
- func Get16MD5Encode(data string) string
- func GetAllFile(pathname string) ([]string, error)
- func GetChineseMonthDay(date string) (rmonth, rday int64)
- func GetMD5Encode(data string) string
- func GetNowPath() string
- func GetPointClassHTML(htmlStr, label, val string) ([]string, error)
- func GetPointHTML(htmlStr, label, attr, val string) ([]string, error)
- func GetPointIDHTML(htmlStr, label, val string) ([]string, error)
- func GetWD() string
- func GzipCompress(src []byte) []byte
- func GzipDecompress(src []byte) []byte
- func HZGB2312To(dstCharset string, src string) (dst string, err error)
- func HexToInt(s string) int
- func HexToInt64(s string) int64
- func HmacMD5(str, key string) string
- func HmacSHA1(str, key string) string
- func HmacSHA256(str, key string) string
- func HmacSHA512(str, key string) string
- func HourAgo(i int) int64
- func ID() int64
- func ID64() (int64, error)
- func IDMd5() string
- func IDShort() int64
- func IDStr() string
- func IF(condition bool, a, b interface{}) interface{}
- func Int64ToByte(i int64) []byte
- func Int64ToHex(i int64) string
- func Int64ToStr(i int64) string
- func IntToByte(i int) []byte
- func IntToHex(i int) string
- func IsContainStr(items []string, item string) bool
- func IsDir(path string) bool
- func IsElementStr(listData []string, element string) bool
- func IsFile(path string) bool
- func IsHaveKey(data map[string]interface{}, key string) bool
- func IsJson(str string) bool
- func IsLeap(year int) bool
- func IsPic(suffix string) bool
- func IsToday(timestamp int64) string
- func IsTodayList(timestamp int64) string
- func IsUtf8(buf []byte) bool
- func JsonFind(jsonStr, find string) (interface{}, error)
- func JsonFind2Arr(jsonStr, find string) ([]interface{}, error)
- func JsonFind2Json(jsonStr, find string) (string, error)
- func JsonFind2Map(jsonStr, find string) (map[string]interface{}, error)
- func JsonToMap(str string) (map[string]interface{}, error)
- func LatestDate(date int) []string
- func Map2Slice(data any) []any
- func MapCopy[K, V comparable](data map[K]V) (copy map[K]V)
- func MapMergeCopy[K, V comparable](src ...map[K]V) (copy map[K]V)
- func MapStrToAny(m map[string]string) map[string]interface{}
- func MapToJson(m interface{}) (string, error)
- func Md5Uppercase(str string) string
- func MinuteAgo(i int) int64
- func NewShortCode() string
- func NowDate() string
- func NowDateHMS() string
- func NowDateLayout(layout string) string
- func NowDateYMD() string
- func NowToEnd() (int64, error)
- func OrderMap[K, V comparable]() *orderMap[K, V]
- func OutJsonFile(data interface{}, fileName string) error
- func P2E()
- func PBKDF2(str, salt []byte, iterations, keySize int) []byte
- func PanicToError(fn func()) (err error)
- func PathExists(path string)
- func RandomIntCaptcha(captchaLen int) string
- func RandomString(list []string) string
- func RegFindAll(regStr, rest string) [][]string
- func RegFindAllTxt(regStr, rest string) (dataList []string)
- func ReplaceAllToOne(str string, from []string, to string) string
- func ResolveTime(seconds int) (day int, hour int, minute int, sy int)
- func ResolveTimeStr(seconds int) string
- func SearchBytesIndex(bSrc []byte, b byte) int
- func SizeFormat(size int64) string
- func Slice2Map(slice any) map[any]any
- func SliceContains[V comparable](a []V, v V) bool
- func SliceCopy[V comparable](a []V) []V
- func SliceDeduplicate[V comparable](a []V) []V
- func SliceDel[V comparable](a []V, i int) []V
- func SliceMax[V number](a []V) V
- func SliceMin[V number](a []V) V
- func SlicePop[V comparable](a []V) (V, []V)
- func SliceReverse[V comparable](a []V) []V
- func SliceShuffle[V comparable](a []V) []V
- func StrDeleteSpace(str string) string
- func StrDuplicates(a []string) []string
- func StrLen(str string) int
- func StrNumToFloat32(str string) float32
- func StrNumToFloat64(str string) float64
- func StrNumToInt(str string) int
- func StrNumToInt32(str string) int32
- func StrNumToInt64(str string) int64
- func StrToByte(s string) []byte
- func StructToMap(obj interface{}) map[string]interface{}
- func StructToMapV2(obj interface{}, hasValue bool) (map[string]interface{}, error)
- func StructToMapV3(obj interface{}) map[string]interface{}
- func TickerRun(t time.Duration, runFirst bool, f func())
- func Timestamp() string
- func Timestamp2Date(timestamp int64) string
- func Timestamp2Week(timestamp int64) string
- func Timestamp2WeekXinQi(timestamp int64) string
- func ToBIG5(srcCharset string, src string) (dst string, err error)
- func ToGB18030(srcCharset string, src string) (dst string, err error)
- func ToGB2312(srcCharset string, src string) (dst string, err error)
- func ToGDK(srcCharset string, src string) (dst string, err error)
- func ToHZGB2312(srcCharset string, src string) (dst string, err error)
- func ToUTF16(srcCharset string, src string) (dst string, err error)
- func ToUTF8(srcCharset string, src string) (dst string, err error)
- func URIStr(url string) string
- func UTF16To(dstCharset string, src string) (dst string, err error)
- func UTF8To(dstCharset string, src string) (dst string, err error)
- func Uint8ToStr(bs []uint8) string
- func UnescapeUnicode(raw []byte) ([]byte, error)
- func UnicodeDec(raw string) string
- func UnicodeDecByte(raw []byte) []byte
- type AES
- type Bar
- type Charset
- type Cron
- func (c *Cron) AddAtDayWhatTime(f func(), i int)
- func (c *Cron) AddAtFriday(f func())
- func (c *Cron) AddAtHours(f func(), i int)
- func (c *Cron) AddAtMinute(f func(), i int)
- func (c *Cron) AddAtMonday(f func())
- func (c *Cron) AddAtSaturday(f func())
- func (c *Cron) AddAtSunday(f func())
- func (c *Cron) AddAtThursday(f func())
- func (c *Cron) AddAtTuesday(f func())
- func (c *Cron) AddAtWednesday(f func())
- func (c *Cron) Run()
- type DES
- type GDMap
- func (m *GDMap) Add(key string, value interface{}) *GDMap
- func (m *GDMap) AddMap(data map[string]interface{}) *GDMap
- func (m *GDMap) CheckValue(value interface{}) bool
- func (m *GDMap) Del(key string) *GDMap
- func (m *GDMap) Get(key string) interface{}
- func (m *GDMap) KeyList() []string
- func (m *GDMap) Len() int
- func (m *GDMap) Range(f func(k string, v interface{})) *GDMap
- func (m *GDMap) RangeAt(f func(id int, k string, v interface{})) *GDMap
- func (m *GDMap) Reverse()
- type GDMaper
- type IdWorker
- type JWT
- func (j *JWT) AddClaims(k string, v interface{}) *JWT
- func (j *JWT) Get(k string) interface{}
- func (j *JWT) GetBool(k string) bool
- func (j *JWT) GetFloat64(k string) float64
- func (j *JWT) GetInt(k string) int
- func (j *JWT) GetInt64(k string) int64
- func (j *JWT) GetString(k string) string
- func (j *JWT) IsExpire() bool
- func (j *JWT) ParseToken(token string) error
- func (j *JWT) Print()
- func (j *JWT) Token() (string, error)
- type Paginator
- func (p *Paginator) HasNext() bool
- func (p *Paginator) HasPages() bool
- func (p *Paginator) HasPrev() bool
- func (p *Paginator) IsActive(page int) bool
- func (p *Paginator) Nums() int64
- func (p *Paginator) Offset() int
- func (p *Paginator) Page() int
- func (p *Paginator) PageLink(page int) string
- func (p *Paginator) PageLinkFirst() string
- func (p *Paginator) PageLinkLast() string
- func (p *Paginator) PageLinkNext() string
- func (p *Paginator) PageLinkPrev() string
- func (p *Paginator) PageNums() int
- func (p *Paginator) Pages() []int
- func (p *Paginator) SetNums(nums interface{})
- type Set
- type Stack
Constants ¶
const ( UTF8 = Charset("UTF-8") GB18030 = Charset("GB18030") GBK = Charset("GBK") GB2312 = Charset("GB2312") )
const ( CBC = "CBC" ECB = "ECB" CFB = "CFB" CTR = "CTR" )
const ( TimeTemplate = "2006-01-02 15:04:05" TimeMilliTemplate = "2006-01-02 15:04:05.000" // 定义每分钟的秒数 SecondsPerMinute = 60 // 定义每小时的秒数 SecondsPerHour = SecondsPerMinute * 60 // 定义每天的秒数 SecondsPerDay = SecondsPerHour * 24 )
const DefaultABC = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
Variables ¶
var Leaps = []int{0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
Leaps 闰年的天数
var Pyears = []int{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
Pyears 平年天数
Functions ¶
func AnyToJsonB ¶
AnyToJsonB interface{} -> json string
func AnyToMap ¶
func AnyToMap(data interface{}) map[string]interface{}
AnyToMap interface{} -> map[string]interface{}
func AnyToStrings ¶
func AnyToStrings(data interface{}) []string
AnyToStrings interface{} -> []string
func Base64UrlDecode ¶
Base64UrlDecode base64 url 解码
func ByteToBinaryString ¶
ByteToBinaryString 字节 -> 二进制字符串
func CompressFiles ¶
CompressFiles 压缩很多文件 files 文件数组,可以是不同dir下的文件或者文件夹 dest 压缩文件存放地址
func ConvertByte2String ¶
ConvertByte2String 编码转换
func ConvertGBKToStr ¶
ConvertGBKToStr 将GBK编码的字符串转换为utf-8编码
func Date2Timestamp ¶
func DayAgoDateYMD ¶
func DecompressionZipFile ¶
DecompressionZipFile zip压缩文件
func DeepEqual ¶
func DeepEqual(a, b interface{}) bool
DeepEqual 深度比较任意类型的两个变量的是否相等,类型一样值一样反回true 如果元素都是nil,且类型相同,则它们是相等的; 如果它们是不同的类型,它们是不相等的
func GetChineseMonthDay ¶
GetChineseMonthDay 获取农历
func GetPointClassHTML ¶
GetPointClassHTML 获取指定标签class属性的html
func GetPointHTML ¶
GetPointHTML 获取指定位置的HTML, 用标签, 标签属性, 属性值来定位
func GetPointIDHTML ¶
GetPointIDHTML 获取指定标签id属性的html
func HZGB2312To ¶
HZGB2312To hzgb2312 to
func IsContainStr ¶
IsContainStr 字符串是否等于items中的某个元素
func IsElementStr ¶
IsElementStr 判断字符串是否与数组里的某个字符串相同
func JsonFind ¶
JsonFind 按路径寻找指定json值 用法参考 ./_examples/json/main.go @find : 寻找路径,与目录的url类似, 下面是一个例子: json: {a:[{b:1},{b:2}]} find=/a/[0] => {b:1} find=a/[0]/b => 1
func JsonFind2Arr ¶
JsonFind2Arr 寻找json,输出 []interface{}
func JsonFind2Json ¶
JsonFind2Json 寻找json,输出 json格式字符串
func JsonFind2Map ¶
JsonFind2Map 寻找json,输出 map[string]interface{}
func MapCopy ¶
func MapCopy[K, V comparable](data map[K]V) (copy map[K]V)
func MapMergeCopy ¶
func MapMergeCopy[K, V comparable](src ...map[K]V) (copy map[K]V)
func MapStrToAny ¶
MapStrToAny map[string]string -> map[string]interface{}
func Md5Uppercase ¶
func NewShortCode ¶ added in v0.1.4
func NewShortCode() string
NewShortCode 获取一个不重复的短code;常用与短链code生成;
func NowDateHMS ¶
func NowDateHMS() string
func NowDateLayout ¶
func NowDateYMD ¶
func NowDateYMD() string
func OrderMap ¶ added in v0.1.4
func OrderMap[K, V comparable]() *orderMap[K, V]
OrderMap ues: OrderMap[K, V]()
func OutJsonFile ¶
OutJsonFile 将data输出到json文件
func RandomIntCaptcha ¶
RandomIntCaptcha 生成 captchaLen 位随机数,理论上会重复
func RandomString ¶
func RegFindAll ¶
func RegFindAllTxt ¶
func ReplaceAllToOne ¶
ReplaceAllToOne 批量统一替换字符串
func ResolveTime ¶
ResolveTime 将传入的“秒”解析为3种时间单位
func ResolveTimeStr ¶
func SearchBytesIndex ¶
SearchBytesIndex []byte 字节切片 循环查找
func Slice2Map ¶
Slice2Map ["K1", "v1", "K2", "v2"] => {"K1": "v1", "K2": "v2"} ["K1", "v1", "K2"] => nil
func SliceContains ¶ added in v0.1.4
func SliceContains[V comparable](a []V, v V) bool
func SliceCopy ¶
func SliceCopy[V comparable](a []V) []V
func SliceDeduplicate ¶ added in v0.1.4
func SliceDeduplicate[V comparable](a []V) []V
func SliceDel ¶ added in v0.1.4
func SliceDel[V comparable](a []V, i int) []V
func SlicePop ¶ added in v0.1.4
func SlicePop[V comparable](a []V) (V, []V)
func SliceReverse ¶ added in v0.1.4
func SliceReverse[V comparable](a []V) []V
func SliceShuffle ¶ added in v0.1.4
func SliceShuffle[V comparable](a []V) []V
func StructToMap ¶
func StructToMap(obj interface{}) map[string]interface{}
StructToMap struct -> map[string]interface{}
func StructToMapV2 ¶
StructToMapV2 Struct -> map hasValue=true表示字段值不管是否存在都转换成map hasValue=false表示字段为不为空或者不为0则转换成map
func StructToMapV3 ¶
func StructToMapV3(obj interface{}) map[string]interface{}
StructToMapV3 struct -> map
func Timestamp2Date ¶
func Timestamp2Week ¶
func Timestamp2WeekXinQi ¶
func ToHZGB2312 ¶
ToHZGB2312 to hzgb2312
func UnicodeDec ¶
func UnicodeDecByte ¶
Types ¶
type AES ¶
type AES interface { Encrypt(str, key []byte) ([]byte, error) Decrypt(str, key []byte) ([]byte, error) }
AES AES interface
type Bar ¶
type Bar struct {
// contains filtered or unexported fields
}
Bar 终端显示的进度条
func (*Bar) NewOptionWithGraph ¶
type Cron ¶
func (*Cron) AddAtDayWhatTime ¶
AddAtDayWhatTime 每天的几点 i=0为每天
type DES ¶
type DES interface { Encrypt(str, key []byte) ([]byte, error) Decrypt(str, key []byte) ([]byte, error) }
DES DES interface
type GDMap ¶
type GDMap struct {
// contains filtered or unexported fields
}
GDMap 固定顺序map
func (*GDMap) CheckValue ¶
CheckValue 查看map是否存在指定的值
type GDMaper ¶
type GDMaper interface { Add(key string, value interface{}) *GDMap Get(key string) interface{} Del(key string) *GDMap Len() int KeyList() []string AddMap(data map[string]interface{}) *GDMap Range(f func(k string, v interface{})) *GDMap RangeAt(f func(id int, k string, v interface{})) *GDMap CheckValue(value interface{}) bool // 检查是否存在某个值 Reverse() //反序 }
GDMaper 固定顺序 Map 接口
type IdWorker ¶
type IdWorker struct {
// contains filtered or unexported fields
}
func (*IdWorker) InitIdWorker ¶
type Paginator ¶
type Paginator struct { Request *http.Request //请求 PerPageNums int // 一页显示多少条记录 MaxPages int //一共有多少页 // contains filtered or unexported fields }
Paginator 分页器
func NewPaginator ¶
NewPaginator 创建分页
type Set ¶
type Set map[any]struct{}
func (Set) DebugPrint ¶ added in v0.1.4
func (s Set) DebugPrint()
type Stack ¶
type Stack[K comparable] struct { // contains filtered or unexported fields }
func NewStack ¶ added in v0.1.4
func NewStack[K comparable]() *Stack[K]
func (*Stack[K]) DebugPrint ¶ added in v0.1.4
func (s *Stack[K]) DebugPrint()