qesygo

package module
v0.0.0-...-dfa0db0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2024 License: BSD-2-Clause Imports: 36 Imported by: 4

README

QesyGo

A simple go class library

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UdpConn *net.UDPConn

Functions

func Abs

func Abs(a int) (ret int)

func AesCBCDecrypt

func AesCBCDecrypt(dst, key, iv []byte) []byte

func AesCBCDncrypt

func AesCBCDncrypt(encryptData, key, iv []byte) ([]byte, error)

微信小程序解密 (获取电话号码等)

func AesCBCEncrypt

func AesCBCEncrypt(src, key, iv []byte) []byte

func AesDecrypt

func AesDecrypt(crypted, key, iv []byte) ([]byte, error)

微信小程序开放数据解密

func AesECBDecrypt

func AesECBDecrypt(dst, key []byte) []byte

func AesECBEncrypt

func AesECBEncrypt(src, key []byte) []byte

func Array_Diff

func Array_Diff(Arr1 []int, Arr2 []int) []int

func Array_Diff_String

func Array_Diff_String(Arr1 []string, Arr2 []string) []string

func Array_Mixed

func Array_Mixed(Arr1 []int, Arr2 []int) []int

func Array_Rand

func Array_Rand(num int) []int

func Array_column

func Array_column(Arr []map[string]string, Str string) []string

func Array_column_index

func Array_column_index(Arr []map[string]string, Str string, Index string) map[string]string

func Array_merge

func Array_merge(arr ...[]string) []string

func Array_merge_int

func Array_merge_int(arr ...[]int) []int

func Array_unique

func Array_unique(Arr []string) []string

func Base64Decode

func Base64Decode(json string) ([]byte, error)

func Base64Encode

func Base64Encode(json string) string

func BytesToInt

func BytesToInt(b []byte) int32

func CheckIdCard

func CheckIdCard(card string) bool

func CheckMobile

func CheckMobile(phone string) bool

func ConvertToString

func ConvertToString(src string, srcCode string, tagCode string) string

转码 ConvertToString( string, "gbk", "utf-8")

func Crontab

func Crontab(f func())

func CrontabMicro

func CrontabMicro(f func())

func Date

func Date(timestamp int64, format string) string

-- format : "2006-01-02 03:04:05 PM" --

@timestamp 传0 ,即现在时间

月份 1,01,Jan,January 日  2,02,_2 时  3,03,15,PM,pm,AM,am 分  4,04 秒  5,05 年  06,2006 周几 Mon,Monday 时区时差表示 -07,-0700,Z0700,Z07:00,-07:00,MST 时区字母缩写 MST

func DateTimeGet

func DateTimeGet() int64

func Die

func Die(v interface{})

func Err

func Err(str string) error

func Explode

func Explode(str string, sep string) []string

func FailOnError

func FailOnError(err error, msg string)

func FileExist

func FileExist(filename string) bool

func Fprintf

func Fprintf(w http.ResponseWriter, str string)

func Get

func Get(url string, para map[string]string) (string, error)

func GetDiffDays

func GetDiffDays(t1, t2 time.Time) int

获取两个时间相差的天数,0表同一天,正数表t1>t2,负数表t1<t2

func GetDiffDaysBySecond

func GetDiffDaysBySecond(t1, t2 int64) int

获取t1和t2的相差天数,单位:秒,0表同一天,正数表t1>t2,负数表t1<t2

func GetDiffDaysBySecondOffset

func GetDiffDaysBySecondOffset(t1, t2, offset int64) int

获取t1和t2的相差天数,单位:秒,0表同一天,正数表t1>t2,负数表t1<t2(带偏移) 使用场景:比如以每天5点为天数计算分界点(同一天4点和6点,算2天)

func HexDecode

func HexDecode(s string) []byte

16进制解码

func HexEncode

func HexEncode(s string) []byte

字符串转为16进制

func Http_build_query

func Http_build_query(para map[string]string) string

* para := map[string]string{"sex":"boy", "age":"18", "name":"老钱"}

func Implode

func Implode(arr []string, sep string) string

func InArray

func InArray(Arr interface{}, str string) bool

func Int64ToInt

func Int64ToInt(num int64) (int, error)

func IntToBytes

func IntToBytes(x int32) []byte

func IntToStr

func IntToStr(a interface{}) string

func IntsToStrs

func IntsToStrs(intArr []int) []string

func JsonDecode

func JsonDecode(str []byte, jsonArr interface{}) error

func JsonEncode

func JsonEncode(arr interface{}) ([]byte, error)

func Keys

func Keys(Arr map[string]string) []string

func Krand

func Krand(size int, kind int) []byte

-- kind 0:纯数字,1:小写,2:大写,3:数字+大小写字幕 --

func Log

func Log(Path string)

func LogSave

func LogSave(Path string)

func Marshal

func Marshal(ProtoId int32, pbStruct proto.Message) ([]byte, error)

func Max

func Max(Para ...int) int

func Md5

func Md5(str string) string

func Min

func Min(Para ...int) int

func PKCS7UnPadding

func PKCS7UnPadding(plantText []byte) []byte

func Post

func Post(url string, paraInterface interface{}) (string, error)

func PostJson

func PostJson(url string, paraInterface interface{}) (string, error)

func Printf

func Printf(format string, a ...interface{})

func Println

func Println(str ...interface{})

func Rand

func Rand(Min int, Max int) int

func Rate

func Rate(num int) bool

func ReadFile

func ReadFile(str string) ([]byte, error)

func RsaEncrypt

func RsaEncrypt(origData []byte, Privatekey []byte) ([]byte, error)

加密

func RsaVeri

func RsaVeri(origData []byte, PublicKey []byte, Sign string) error

func SHA1

func SHA1(str string) string

func SocketListenUdp

func SocketListenUdp(Ip string, f func())

func Str2Lower

func Str2Lower(Str string) string

func Str2Title

func Str2Title(Str string) string

func Str2Upper

func Str2Upper(Str string) string

func StrToInt

func StrToInt(str string) int

func StrToInt32

func StrToInt32(str string) int32

func StrToInt64

func StrToInt64(str string) int64

func StrToTime

func StrToTime(format string, input string) int64

format:2006-01-02 15:04:05, input:2023-12-31 12:59:59

func StrToTimeByDate

func StrToTimeByDate(format string, input string) int64

-- "01/02/2006", "02/08/2015" --

func StrsToInts

func StrsToInts(StrArr []string) []int

func Substr

func Substr(str string, start int, end int) string

func Time

func Time(str string) int64

func TimeStr

func TimeStr(str string) string

func UnHttp_build_query

func UnHttp_build_query(Str string) map[string]string

func Unmarshal

func Unmarshal(data []byte, pbStruct proto.Message) error

func Unset

func Unset(arr []string, str string) []string

func UrlDeCode

func UrlDeCode(str string) string

func UrlEnCode

func UrlEnCode(str string) string

func VeriPara

func VeriPara(Req map[string]string, Para []string) bool

func Week

func Week() int

func Wordwrap

func Wordwrap(Str string, width int, breakStr string) string

Types

type ByAge

type ByAge []Person

ByAge implements sort.Interface for []Person based on the Age field.

func (ByAge) Len

func (a ByAge) Len() int

func (ByAge) Less

func (a ByAge) Less(i, j int) bool

func (ByAge) Swap

func (a ByAge) Swap(i, j int)

type CacheRedis

type CacheRedis struct {
	Pool     *redis.Pool // redis connection pool
	Conninfo string
	Auth     string
}

func (*CacheRedis) Connect

func (cr *CacheRedis) Connect() error

var pool = newPool()

func (*CacheRedis) Del

func (cr *CacheRedis) Del(key ...string) error

func (*CacheRedis) Exists

func (cr *CacheRedis) Exists(key string) (bool, error)

func (*CacheRedis) Expire

func (cr *CacheRedis) Expire(key string, second int) (bool, error)

func (*CacheRedis) FlushAll

func (cr *CacheRedis) FlushAll() error

func (*CacheRedis) Get

func (cr *CacheRedis) Get(key string) (string, error)

func (*CacheRedis) HGet

func (cr *CacheRedis) HGet(key string, subKey string) (interface{}, error)

func (*CacheRedis) HGetAll

func (cr *CacheRedis) HGetAll(key string) (map[string]string, error)

func (*CacheRedis) HMset

func (cr *CacheRedis) HMset(key string, arr interface{}) (interface{}, error)

func (*CacheRedis) Keys

func (cr *CacheRedis) Keys(key string) ([]string, error)

func (*CacheRedis) SAdd

func (cr *CacheRedis) SAdd(Key string, Val string) (int, error)

func (*CacheRedis) SCard

func (cr *CacheRedis) SCard(Key string) (interface{}, error)

func (*CacheRedis) SIsMembers

func (cr *CacheRedis) SIsMembers(Key string, Val string) (int, error)

func (*CacheRedis) SMembers

func (cr *CacheRedis) SMembers(Key string, Val string) (interface{}, error)

func (*CacheRedis) SRem

func (cr *CacheRedis) SRem(Key string, Val ...string) (interface{}, error)

func (*CacheRedis) Set

func (cr *CacheRedis) Set(key string, value string) error

func (*CacheRedis) SetEx

func (cr *CacheRedis) SetEx(key string, expire int, value string) (string, error)

func (*CacheRedis) SetNx

func (cr *CacheRedis) SetNx(key string, value string) (int, error)

func (*CacheRedis) Ttl

func (cr *CacheRedis) Ttl(key string) (interface{}, error)

func (*CacheRedis) ZAdd

func (cr *CacheRedis) ZAdd(Key string, Score int64, Name string) (interface{}, error)

func (*CacheRedis) ZCard

func (cr *CacheRedis) ZCard(Key string) (int, error)

func (*CacheRedis) ZCount

func (cr *CacheRedis) ZCount(Key string, Min int32, Max int32) (int, error)

func (*CacheRedis) ZRange

func (cr *CacheRedis) ZRange(Key string, Start int32, End int32) ([][2]int64, error)

func (*CacheRedis) ZRank

func (cr *CacheRedis) ZRank(Key string, Name string) (int, error)

func (*CacheRedis) ZRem

func (cr *CacheRedis) ZRem(Key string, Name string) (interface{}, error)

func (*CacheRedis) ZRevRange

func (cr *CacheRedis) ZRevRange(Key string, Start int32, End int32) ([][2]int64, error)

func (*CacheRedis) ZRevRank

func (cr *CacheRedis) ZRevRank(Key string, Name string) (int, error)

type CurlModel

type CurlModel struct {
	Url      string
	Para     map[string]string
	Method   string
	IsHttps  bool
	Header   map[string]string
	IsJson   bool
	IsDebug  bool
	Body     []byte
	IsCert   bool //是否验证证书
	CertFile string
	KeyFile  string
}

func (*CurlModel) ExecGet

func (c *CurlModel) ExecGet() ([]byte, error)

func (*CurlModel) ExecPost

func (c *CurlModel) ExecPost() ([]byte, error)

func (*CurlModel) SetBody

func (c *CurlModel) SetBody(Body []byte) *CurlModel

func (*CurlModel) SetCert

func (c *CurlModel) SetCert(certFile string, keyFile string) *CurlModel

func (*CurlModel) SetHeader

func (c *CurlModel) SetHeader(Header map[string]string) *CurlModel

func (*CurlModel) SetIsDebug

func (c *CurlModel) SetIsDebug(IsDebug bool) *CurlModel

func (*CurlModel) SetIsHttps

func (c *CurlModel) SetIsHttps(IsHttps bool) *CurlModel

func (*CurlModel) SetIsJson

func (c *CurlModel) SetIsJson(IsJson bool) *CurlModel

func (*CurlModel) SetMethod

func (c *CurlModel) SetMethod(Method string) *CurlModel

func (*CurlModel) SetPara

func (c *CurlModel) SetPara(Para map[string]string) *CurlModel

func (*CurlModel) SetUrl

func (c *CurlModel) SetUrl(Url string) *CurlModel

type Person

type Person struct {
	Name string
	Age  int
}

type RandWeiht

type RandWeiht struct {
	Name   string
	Weight int
}

type RandWeihtArr

type RandWeihtArr []RandWeiht

func (*RandWeihtArr) RandWeight

func (arr *RandWeihtArr) RandWeight() string

* RandWeihtArr := &lib.RandWeihtArr{{"user1",8}, {"user2",1},{"user3",1}} * who := RandWeihtArr.RandWeight()

type Worker

type Worker struct {
	// contains filtered or unexported fields
}

func NewWorker

func NewWorker(workerId int64) (*Worker, error)

实例化对象

func (*Worker) Next

func (w *Worker) Next() int64

获取一个新ID

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL