Documentation
¶
Index ¶
- Constants
- Variables
- func ArrDel[T StrNumber](s []T, elem T) []T
- func ArrWalk[T any, S any](s []T, walkFunc func(index int, item T) S) []S
- func CRC32BigFile(f *os.File) string
- func CRC32Encode(input []byte) string
- func CaptchaGenerate() (string, string, error)
- func CaptchaGenerate1() (string, string, error)
- func CaptchaVerify(id, VerifyValue string) bool
- func CheckImageExt(fileName string, exts []string) bool
- func CheckImageSize(fileHeader *multipart.FileHeader, maxSize int) bool
- func CheckPath(src string) error
- func ConvertExcelDateToFormatDay(excelDaysString string) string
- func ConvertToStringMap(data interface{}) map[string]string
- func ConvertToStringMapRecursively(prefix string, data interface{}, result map[string]string)
- func Copy(src, dst string) error
- func CopyDir(src, dst string) error
- func DeepCopyMap(src map[int64]interface{}) map[int64]interface{}
- func DownloadFile(c *gin.Context, path, name string) error
- func FindToken(c *gin.Context, cookieKey string) string
- func FindUser(c *gin.Context) *model.User
- func FindUserId(c *gin.Context) int64
- func GenerateRandomString(length int) string
- func GenerateToken(username, accessToken string, expiredAt int64, userType int, jwtSecret []byte) (string, error)
- func GeoDistance(lat1, lon1, lat2, lon2 float64) float64
- func GetArrayMaybeValue[T string](arr []T, index int) T
- func GetDaysInMonth(year int, month time.Month) int
- func GetDefaultCacheMemory() *cache.Cache
- func GetImageBase64Content(fileName, suffix string) (string, error)
- func GetImageName(name string) string
- func GetRandomWithAll(min, max int) int64
- func GetTimeConditionWhere(req *request.TimeConditionRule) map[string]map[string]interface{}
- func GetWSSessionKey(header http.Header) string
- func GetWSSessionKeyByKey(platFormKey int) string
- func GetWeek(year int, month time.Month, day int) (latestDay time.Weekday)
- func GetWeekendInYear(timestamp int64) int
- func HttpFile(c *gin.Context, filepath string, filename string)
- func HttpReturn(c *gin.Context, httpCode int, errCode code.ErrCode, err error, ...)
- func HttpReturn500(c *gin.Context, errCode code.ErrCode, err error, data interface{})
- func HttpReturnOK(c *gin.Context, errCode code.ErrCode, err error, data interface{})
- func HttpReturnValidateFailed(c *gin.Context, err error, data interface{})
- func Image2Base64(fileName string) (string, error)
- func InArrStrNum[T StrNumber](s []T, needle T) bool
- func InArrStruct[T any](s []T, needle T, eqFunc func(i, needle T) bool) bool
- func InRange(points []Point, point *Point) bool
- func IsNight(t time.Time) bool
- func IsStringEmpty(str string) bool
- func IsWeekend(t time.Time) bool
- func MD5BigFile(f *os.File) string
- func MD5BytesEncode(value []byte) string
- func MD5Encode(value string) string
- func MergeStructs(dst interface{}, srcs ...interface{}) error
- func NewCacheMemory(defaultExpiration, cleanupInterval time.Duration) *cache.Cache
- func OverrideGinValidator()
- func ParseStrTimeCondition2Int(timeCondition *TimeCondition, timeField string, where map[string]interface{}) map[string]interface{}
- func PasswordHash(pwd []byte) string
- func PasswordVerify(hashedPwd string, plainPwd string) bool
- func RequestPlatform(header http.Header) int
- func RequestPlatformByXPlatformFrom(XPlatformFrom string) int
- func SmsCaptchaGenerate(phone string) string
- func SmsCaptchaVerify(phone string, code string) (bool, error)
- func StrPad(str string, placeholder string, overallLen int) string
- func Translate(err error) string
- func TrimHandlerName(handlerName string) string
- func UUID(nodeId int64) string
- func UnZip()
- func UniqueArrStrNum[T StrNumber](s []T) []T
- func Upload(c *gin.Context, uploadFile *multipart.FileHeader, dir string) (string, error)
- func UploadFile(f io.Reader, storagePath, filename string) (string, string, error)
- func UploadFileByMultipartFileHeader(f *multipart.FileHeader, storagePath string) (string, string, error)
- func UploadPath(dir, filename string) string
- func WGS84ToCGCS2000(lon, lat float64) []float64
- func Zip(src, dst string) error
- type Area
- type Claims
- func (c Claims) GetAudience() (jwt.ClaimStrings, error)
- func (c Claims) GetExpirationTime() (*jwt.NumericDate, error)
- func (c Claims) GetIssuedAt() (*jwt.NumericDate, error)
- func (c Claims) GetIssuer() (string, error)
- func (c Claims) GetNotBefore() (*jwt.NumericDate, error)
- func (c Claims) GetSubject() (string, error)
- type Config
- type Email
- type HttpResponse
- type ID
- func ParseBase2(id string) (ID, error)
- func ParseBase32(b []byte) (ID, error)
- func ParseBase36(id string) (ID, error)
- func ParseBase58(b []byte) (ID, error)
- func ParseBase64(id string) (ID, error)
- func ParseBytes(id []byte) (ID, error)
- func ParseInt64(id int64) ID
- func ParseIntBytes(id [8]byte) ID
- func ParseString(id string) (ID, error)
- 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 Mail
- type Node
- type Number
- type Point
- type SmsCode
- type StrNumber
- type TimeCondition
Constants ¶
const R = 6367000 // 地球平均半径(单位为千米)
Variables ¶
var ( // Epoch is set to the twitter snowflake epoch of Nov 04 2010 01:42:54 UTC in milliseconds // You may customize this to set a different epoch for your application. Epoch int64 = 1288834974657 // NodeBits holds the number of bits to use for Node // Remember, you have a total 22 bits to share between Node/Step NodeBits uint8 = 10 // StepBits holds the number of bits to use for Step // Remember, you have a total 22 bits to share between Node/Step StepBits uint8 = 12 )
var CacheMemory *cache.Cache
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 CRC32BigFile ¶
func CRC32Encode ¶
func CaptchaGenerate ¶
func CaptchaGenerate1 ¶
func CaptchaVerify ¶
func CheckImageExt ¶
CheckImageExt check image file ext
func CheckImageSize ¶
func CheckImageSize(fileHeader *multipart.FileHeader, maxSize int) bool
CheckImageSize check image size
func ConvertExcelDateToFormatDay ¶
ConvertExcelDateToFormatDay excel日期字段格式化 yyyy-mm-dd
func ConvertToStringMap ¶
ConvertToStringMap 将一个数据结构转换为字符串键值对
func ConvertToStringMapRecursively ¶
ConvertToStringMapRecursively 递归地将数据结构转换为字符串键值对
func DeepCopyMap ¶
func FindUserId ¶
func GenerateRandomString ¶
func GenerateToken ¶
func GenerateToken(username, accessToken string, expiredAt int64, userType int, jwtSecret []byte) (string, error)
GenerateToken generate tokens used for auth
func GeoDistance ¶
func GetArrayMaybeValue ¶
func GetDaysInMonth ¶
GetDaysInMonth 返回指定年份和月份的天数
func GetDefaultCacheMemory ¶
func GetImageBase64Content ¶
GetImageBase64Content 获取 图片的 base64 内容 xxx.jpg ===> xxx.base64
func GetRandomWithAll ¶
GetRandomWithAll 获取指定范围的随机整数,包含上下限
func GetTimeConditionWhere ¶
func GetTimeConditionWhere(req *request.TimeConditionRule) map[string]map[string]interface{}
func GetWSSessionKey ¶
func GetWSSessionKeyByKey ¶
func GetWeekendInYear ¶
func HttpReturn ¶
func HttpReturn500 ¶
func HttpReturnOK ¶
func Image2Base64 ¶
func InArrStrNum ¶
func InArrStruct ¶
func IsStringEmpty ¶
func MD5BigFile ¶
func MD5BytesEncode ¶
func MergeStructs ¶
func MergeStructs(dst interface{}, srcs ...interface{}) error
MergeStructs 将多个源结构体的字段值合并到目标结构体中。 dst 是目标结构体的指针,srcs 是源结构体的切片。 函数会尝试将源结构体中每个字段的值复制到目标结构体对应的字段中。 如果目标结构体中有对应的字段且可设置,则进行值的复制。 参数:
dst - 目标结构体的指针,其值将被源结构体的值更新。 srcs - 源结构体的切片,其值将被复制到目标结构体。
返回值:
error - 如果操作中出现错误,则返回错误;否则返回nil。
func NewCacheMemory ¶
func OverrideGinValidator ¶
func OverrideGinValidator()
func ParseStrTimeCondition2Int ¶
func ParseStrTimeCondition2Int(timeCondition *TimeCondition, timeField string, where map[string]interface{}) map[string]interface{}
func PasswordHash ¶
func PasswordVerify ¶
func RequestPlatform ¶
func SmsCaptchaGenerate ¶
func TrimHandlerName ¶
func UniqueArrStrNum ¶
func UniqueArrStrNum[T StrNumber](s []T) []T
func UploadFile ¶
func UploadPath ¶
func WGS84ToCGCS2000 ¶
Types ¶
type Claims ¶
type Claims struct {
Username string `json:"username,omitempty"`
AccessToken string `json:"access_token,omitempty"`
ExpiresAt *jwt.NumericDate `json:"expires_at,omitempty"`
IssuedAt *jwt.NumericDate `json:"iat,omitempty"`
Audience []string `json:"aud,omitempty"`
Id string `json:"jti,omitempty"`
Issuer string `json:"iss,omitempty"`
NotBefore *jwt.NumericDate `json:"nbf,omitempty"`
Subject string `json:"sub,omitempty"`
}
func ParseToken ¶
ParseToken parsing token
func (Claims) GetAudience ¶
func (c Claims) GetAudience() (jwt.ClaimStrings, error)
func (Claims) GetExpirationTime ¶
func (c Claims) GetExpirationTime() (*jwt.NumericDate, error)
func (Claims) GetIssuedAt ¶
func (c Claims) GetIssuedAt() (*jwt.NumericDate, error)
func (Claims) GetNotBefore ¶
func (c Claims) GetNotBefore() (*jwt.NumericDate, error)
func (Claims) GetSubject ¶
type HttpResponse ¶
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 ParseBase2 ¶
ParseBase2 converts a Base2 string into a snowflake 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.
func ParseBase36 ¶
ParseBase36 converts a Base36 string into a snowflake ID
func ParseBase58 ¶
ParseBase58 parses a base58 []byte into a snowflake ID
func ParseBase64 ¶
ParseBase64 converts a base64 string into a snowflake ID
func ParseBytes ¶
ParseBytes converts a byte slice into a snowflake ID
func ParseIntBytes ¶
ParseIntBytes converts an array of bytes encoded as big endian integer as a snowflake ID
func ParseString ¶
ParseString converts a string 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.
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) Node ¶
Node returns an int64 of the snowflake ID node number DEPRECATED: the below function will be removed in a future release.
func (ID) Step ¶
Step returns an int64 of the snowflake step (or sequence) number DEPRECATED: the below function will be removed in a future release.
func (ID) Time ¶
Time returns an int64 unix timestamp in milliseconds of the snowflake ID time DEPRECATED: the below function will be removed in a future release.
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