Documentation
¶
Index ¶
- Constants
- Variables
- func AesDecrypt(crypted, key, iv []byte) ([]byte, error)
- func AesEncrypt(plaintext, key, iv []byte) ([]byte, error)
- func ApiSign(params url.Values, secret string) string
- func ApiSignIsValid(params url.Values, secret string) bool
- func Base64(src []byte) string
- func BcryptEncrypt(message []byte) ([]byte, error)
- func BuildRequestUrl(requestUrl string, params url.Values) string
- func ByteToGByte(byte_value float64) string
- func BytesToUInt(b []byte) uint32
- func CacheCount() int
- func CacheDel(key string)
- func CacheGetBool(key string) (value bool, ok bool)
- func CacheGetByteArray(key string) (value []byte, ok bool)
- func CacheGetInt(key string) (value int, ok bool)
- func CacheGetInt64(key string) (value int64, ok bool)
- func CacheGetString(key string) (value string, ok bool)
- func CacheGetTime(key string) (value time.Time, ok bool)
- func CacheSet(key string, value interface{})
- func CheckBcrypt(hashBytes, s []byte) (bool, error)
- func ConfusedTwo(sourceBytes []byte) []byte
- func DesDecrypt(crypted, key, iv []byte) ([]byte, error)
- func DesEncrypt(origData, key, iv []byte) ([]byte, error)
- func FormatJson(data interface{}) string
- func From2000Nano() int64
- func GenerateSign(params map[string]string, secret string, taobao_nick string, time int64) string
- func GenerateSignNoUser(params map[string]string, secret string) string
- func Get(requestUrl string) (int, string, error)
- func GetByAuthToken(requestUrl, authToken string) (int, string, error)
- func GetByToken(requestUrl, token string) (int, string, error)
- func GetCRC32(s string) uint32
- func GetCurrentDirectory() string
- func GetCurrentIntranetIP() string
- func GetDate(t time.Time) int
- func GetFileSuffix(s string) string
- func GetGuid() string
- func GetIPAddressNotPort(ip_address string) string
- func GetIPNums(s string) (ipNum uint32, err error)
- func GetPwd(lenth int) string
- func GetSimplePwd(lenth int) string
- func GetTimeInt64() int64
- func HTMLEncode(s string) string
- func HexStringToBytes(hex_str string) []byte
- func HmacMd5(message, secret []byte) []byte
- func HmacSha1(message, secret []byte) []byte
- func HmacSha256(message, secret []byte) []byte
- func HmacSha512(message, secret []byte) []byte
- func IsAllChineseChar(s string) bool
- func IsAscii(s string) bool
- func IsEmail(s string) bool
- func IsGeneralString(s string) bool
- func IsHanOrLetterOrNumber(s string) bool
- func IsIPAddress(s string) bool
- func IsIntranetIP(s string) bool
- func IsLetterOrNumber(s string) bool
- func IsLetterOrNumber1(s string) bool
- func IsMobile(s string) bool
- func IsMultipNumber(s string) bool
- func IsNumber(s string) bool
- func IsStandardTime(s string) bool
- func IsSubTaobaoNick(s string) bool
- func IsTaobaoNick(s string) bool
- func IsUrl(s string) bool
- func IsUtf8(s string) bool
- func IsVersion(s string) bool
- func Length(str string) int
- func Md5(s string) string
- func Method(r *http.Request) string
- func PKCS7Padding(ciphertext []byte, blockSize int) []byte
- func PKCS7Unpadding(origData []byte) []byte
- func ParseRequestQuery(req string) (params url.Values, err error)
- func Post(requestUrl string, params url.Values) (int, string, error)
- func PostBody(requestUrl string, reqBody string) (int, string, error)
- func PostByAuthToken(requestUrl string, authToken string, params url.Values) (int, string, error)
- func PostByToken(requestUrl, token string) (int, string, error)
- func PostFile(requestUrl string, params url.Values, field_name, path string) (int, string, error)
- func PostJson(requestUrl string, params map[string]string) (int, string, error)
- func PostJsonByToken(requestUrl, token, jsonString string) (int, string, error)
- func RandInt64(min, max int64) int64
- func ReversalBytes(source []byte) []byte
- func ReverseString(s string) string
- func Sha1(message []byte) []byte
- func Since(t time.Time) int64
- func Sleep(t time.Time, delay int64)
- func SliceByteToString(b []byte) string
- func StandardTime() string
- func Strim(s string) string
- func String2Unicode(s string) string
- func StringToSliceByte(s string) []byte
- func SubString(s string, pos, length int) string
- func TimeStringToTime(sourceTime string) (time.Time, error)
- func ToConfusedBase64(str string) string
- func ToConfusedZipBase64(str string) string
- func ToJson(data interface{}) string
- func ToJsonConfusedBase64(obj interface{}) string
- func ToJsonZipConfusedBase64(obj interface{}) string
- func TopSign(params url.Values, secret string) string
- func UIntToBytes(value uint32) []byte
- func UnBase64(source string) ([]byte, error)
- func UnConfusedTwo(confusedBytes []byte) []byte
- func UnZipMd5(zip_string string) (md5_string string, err error)
- func Unicode2String(s string) (to string, err error)
- func Unix() int64
- func UnixMilliSecond() int64
- func UnixNano() int64
- func UrlDecode(source string) (string, error)
- func UrlEncode(source string) string
- func Version2Time(version string) (t time.Time, err error)
- func ZipMd5(md5String string) (zip_string string, err error)
- func ZlibUnzipBytes(input []byte) ([]byte, error)
- func ZlibZipBytes(input []byte) ([]byte, error)
- type ID
- func (f ID) Base2() string
- func (f ID) Base32() string
- func (f ID) Base36() string
- func (f ID) Base58() string
- func (f ID) Base64() string
- func (f ID) Bytes() []byte
- func (f ID) Int64() int64
- func (f ID) IntBytes() [8]byte
- func (f ID) MarshalJSON() ([]byte, error)
- func (f ID) Node() int64
- func (f ID) Step() int64
- func (f ID) String() string
- func (f ID) Time() int64
- func (f *ID) UnmarshalJSON(b []byte) error
- type JSONSyntaxError
- type Node
- type StringBuilder
Constants ¶
const ( Time_TIMEyyyyMMdd string = "20060102" Time_TIMEStandard string = "2006-01-02 15:04:05" Time_TIME_HH_mm_ss string = "15:04:05" Time_TIMEMSSQL string = "2006-01-02T15:04:05.999Z" Time_TIMEMYSQL string = "2006-01-02T15:04:05+08:00" Time_TIMEyyyyMMddHHmmss string = "20060102150405" Time_TIMEyyyyMMddHHmmssffff string = "200601021504059999" Time_TIMEJavaUtilDate string = "20060102150405000-0700" Time_TIMEISO8601 string = "2006-01-02T15:04:05.999-0700" )
const VERSION = "2020.605.1840"
Variables ¶
var ( // Epoch is set to the twitter snowflake epoch of Nov 04 2010 01:42:54 UTC // You may customize this to set a different epoch for your application. Epoch int64 = 1288834974657 // Number of bits to use for Node // Remember, you have a total 22 bits to share between Node/Step NodeBits uint8 = 10 // Number of bits to use for Step // Remember, you have a total 22 bits to share between Node/Step StepBits uint8 = 12 )
var ( GetFileSuffixRegex = regexp.MustCompile(".(jpg|jpeg|png|gif|exe|doc|docx|ppt|pptx|xls|xlsx)") IsTaobaoNickRegex = regexp.MustCompile(`(^[\\u4e00-\\u9fa5\\w_—\\-,。…·〔〕()!@¥%……&*?、;‘“]*$)`) IsSubTaobaoNickRegex = regexp.MustCompile(`(^[\\u4e00-\\u9fa5\\w_—\\-,。…·〔〕()!@¥%……&*?、;‘“:]*$)`) IsVersionRegex = regexp.MustCompile(`(^[0-9.]*$)`) IsUrlRegex = regexp.MustCompile(`(^[a-zA-z]+://[^\s]*$)`) IsNumberRegex = regexp.MustCompile(`(^[0-9]*$)`) IsAsciiRegex = regexp.MustCompile(`(^[\x00-\xff]*$)`) IsMultipNumberRegex = regexp.MustCompile(`(^[0-9,]*$)`) IsLetterOrNumberRegex = regexp.MustCompile(`(^[A-Za-z0-9_]*$)`) IsLetterOrNumber1Regex = regexp.MustCompile(`(^[A-Za-z0-9_-]*$)`) IsHanOrLetterOrNumberRegex = regexp.MustCompile("^[A-Za-z0-9_\u4e00-\u9fa5-]*$") IsGeneralStringRegex = regexp.MustCompile("^[A-Za-z0-9_\\-#+./:\u4e00-\u9fa5]*$") IsStandardTimeRegex = regexp.MustCompile(`^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\s+(20|21|22|23|[0-1]\d):[0-5]\d:[0-5]\d$`) IsIPAddressRegecx = regexp.MustCompile(`^((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}$`) IsIntranetIPRegex = regexp.MustCompile(`^(127\.0\.0\.1)|(10\.\d{1,3}\.\d{1,3}\.\d{1,3})|(172\.((1[6-9])|(2\d)|(3[01]))\.\d{1,3}\.\d{1,3})|(192\.168\.\d{1,3}\.\d{1,3})$`) IsEmailRegex = regexp.MustCompile(`^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$`) IsMobileRegex = regexp.MustCompile("^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][2,5,6,7])|([7][0-8])|([8][0-9])|([9][1,3,5,8,9]))[0-9]{8}$") )
var ErrInvalidBase32 = errors.New("invalid base32")
ErrInvalidBase32 is returned by ParseBase32 when given an invalid []byte
var ErrInvalidBase58 = errors.New("invalid base58")
ErrInvalidBase58 is returned by ParseBase58 when given an invalid []byte
Functions ¶
func AesDecrypt ¶
func AesEncrypt ¶
func BcryptEncrypt ¶
func BuildRequestUrl ¶
获取url和参数列表对应的完整请求url
func ByteToGByte ¶
func CacheCount ¶
func CacheCount() int
func CacheGetBool ¶
func CacheGetByteArray ¶
func CacheGetInt ¶
func CacheGetInt64 ¶
func CacheGetString ¶
func CheckBcrypt ¶
func DesDecrypt ¶
func DesEncrypt ¶
func GenerateSign ¶
func GetByAuthToken ¶
带上AuthToken,发起一个get请求
func GetByToken ¶
带上Bearer Token,发起一个get请求
func HmacSha256 ¶
func HmacSha512 ¶
func PKCS7Padding ¶
func PKCS7Unpadding ¶
func ParseRequestQuery ¶
解析请求参数到一个url.Values对象
func PostByAuthToken ¶
获取url对应的内容,返回信息:StatusCode,body,err
func PostByToken ¶
带上Bearer Token,发起一个post请求,无内容
func PostJsonByToken ¶
带上Bearer Token,发起一个post请求,内容是json
func ToJsonZipConfusedBase64 ¶
func ToJsonZipConfusedBase64(obj interface{}) string
序列化-->zlib压缩-->混淆-->base64
func Version2Time ¶
版本号转时间,格式:2019.905.1052
func ZlibUnzipBytes ¶
func ZlibZipBytes ¶
Types ¶
type ID ¶
type ID int64
An ID is a custom type used for a snowflake ID. This is used so we can attach methods onto the ID.
func ParseBase32 ¶
ParseBase32 parses a base32 []byte into a snowflake ID NOTE: There are many different base32 implementations so becareful when doing any interoperation interop with other packages.
func ParseBase58 ¶
ParseBase58 parses a base58 []byte into a snowflake ID
func (ID) Base32 ¶
Base32 uses the z-base-32 character set but encodes and decodes similar to base58, allowing it to create an even smaller result string. NOTE: There are many different base32 implementations so becareful when doing any interoperation interop with other packages.
func (ID) IntBytes ¶
IntBytes returns an array of bytes of the snowflake ID, encoded as a big endian integer.
func (ID) MarshalJSON ¶
MarshalJSON returns a json byte array string of the snowflake ID.
func (*ID) UnmarshalJSON ¶
UnmarshalJSON converts a json byte array of a snowflake ID into an ID type.
type JSONSyntaxError ¶
type JSONSyntaxError struct {
// contains filtered or unexported fields
}
A JSONSyntaxError is returned from UnmarshalJSON if an invalid ID is provided.
func (JSONSyntaxError) Error ¶
func (j JSONSyntaxError) Error() string
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
A Node struct holds the basic information needed for a snowflake generator node
type StringBuilder ¶
type StringBuilder struct {
// contains filtered or unexported fields
}
func NewStringBuilder ¶
func NewStringBuilder() *StringBuilder
func (*StringBuilder) Append ¶
func (this *StringBuilder) Append(obj interface{}) *StringBuilder
func (*StringBuilder) ToString ¶
func (this *StringBuilder) ToString() string
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
gbtree
B+ Tree
|
B+ Tree |
gchan
优雅的Channel操作.
|
优雅的Channel操作. |
glist
并发安全的双向链表.
|
并发安全的双向链表. |
gmap
并发安全的哈希MAP.
|
并发安全的哈希MAP. |
gqueue
并发安全的动态队列.
|
并发安全的动态队列. |
gset
并发安全的集合SET.
|
并发安全的集合SET. |
Goroutine池.
|
Goroutine池. |
时间管理
|
时间管理 |
gconv
类型转换.
|
类型转换. |
gidgen
ID生成器.
|
ID生成器. |
grand
随机数管理
|
随机数管理 |
gregx
正则表达式
|
正则表达式 |
gutil
其他工具包
|
其他工具包 |