Documentation
¶
Overview ¶
Package utils @Author: cobol @Comment: 时间相关工具 - 注意: 考虑到时区因素, 所有时间都是UTC时间
Index ¶
- Constants
- Variables
- func CurrentTime() time.Time
- func Date() (int, int, int)
- func DateOf(now time.Time) (int, int, int)
- func Dec2Hex(val int) string
- func DecodeUserId(icode string) (int, error)
- func EncodeUserId(uid uint64) string
- func EncryptedPassword(pwd string) string
- func GenVCode() string
- func GenerateRangeNum(min, max int) int
- func GetAreaByIp(ipAddress string) string
- func GetBillNo(prefix string, n int) string
- func GetBillNoInt(prefix string, n int) string
- func GetDateTimeByUnix(ts int64) string
- func GetDateTimeByUnixMicro(ts int64) string
- func GetDayEnd() time.Time
- func GetDayStart() time.Time
- func GetFieldByStruct(v interface{}, field string) string
- func GetIpV6AreaFromUrl(ipAddress string) string
- func GetLastMonthEnd() time.Time
- func GetLastMonthStart() time.Time
- func GetLastWeekEnd() time.Time
- func GetLastWeekStart() time.Time
- func GetMonthEnd() time.Time
- func GetMonthStart() time.Time
- func GetPassword(password, secret string) string
- func GetRandString(n uint) string
- func GetRealPass(password, salt string) string
- func GetSecret() string
- func GetTimeByUnix(ts int64) time.Time
- func GetTimeByUnixMicro(int64Time int64) time.Time
- func GetTodayEnd() time.Time
- func GetTodayStart() time.Time
- func GetUnixByDateTime(dateTime string) int64
- func GetUnixMicroByDateTime(dateTime string) int64
- func GetWeekEnd() time.Time
- func GetWeekStart() time.Time
- func GetYesterdayEnd() time.Time
- func GetYesterdayStart() time.Time
- func GoID() int
- func Hex2Dec(val string) (int, error)
- func HttpGet(url string) (string, error)
- func HttpPost(url string, requestBody []byte, bodyType int) (string, error)
- func InSlice[...](arr []T, ele T) bool
- func IsIPv4(ipAddress string) bool
- func IsIPv6(ipAddress string) bool
- func LoadIpV6Data()
- func MD5(str string) string
- func MD5Str(data string) string
- func MessageChannel(phone string, code string, tmp int) error
- func MessageChannelSecond(phone string, code string, tmp int) error
- func MessageChannelSpare(phone string, code string, tmp int) error
- func MicroToSecond(micro int64) int64
- func Now() time.Time
- func NowMicro() int64
- func NowMills() int64
- func NowSecs() int64
- func PKCS7Padding(ciphertext []byte) []byte
- func PKCS7UnPadding(plantText []byte) []byte
- func RandInt64(min, max int64) int64
- func RandString(n int) string
- func SHA256(v string) string
- func SecondToMicro(second int64) int64
- func Secret() string
- func SendEmail(email, title, content string) error
- func SendSMS(phone string, code string, tmp int, channel string) error
- func SetStructFieldByJsonName(ptr interface{}, fields map[string]string)
- func StructureToMap(request interface{}, tagInfo string) map[string]interface{}
- func StructureToMapNew(item interface{}) map[string]interface{}
- func StructureToSlice(request interface{}, tagInfo string) []string
- func Time() time.Time
- func Timestamp() int64
- func VerifyPassword(pwd, enPwd string) bool
- func WriteIpV6Data(ipAddress, area string)
- type ZxincV6
Constants ¶
const BaseTimeMicro = 4070880000
BaseTimeMicro 默认微秒累加 - 2099-01-01 00:00:00
const IP_V6_URL = "https://ip.zxinc.org/api.php?type=json&ip="
IP_V6_URL 用于临时处理ipv6的数据库
const SecretKey = "0jas3^128*@#*Ls]/<M';sdf3Dnbm?@$"
SecretKey 后台加密用到的KEY, 切勿改动
const ServerKey = "a!k@9#d%9*&aDQK-=bv<M+3456*8c0}@"
ServerKey 服务器端的key
Variables ¶
var Letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678")
Letters 默认的可用字符
var McryptLetters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
McryptLetters 用于生成随机字符串的值
var McryptLettersLower = []rune("abcdefghijklmnopqrstuvwxyz0123456789")
McryptLettersLower 用于生成随机字符串的值
Functions ¶
func GetDateTimeByUnixMicro ¶
GetDateTimeByUnixMicro 通过unix获取时间 - 微秒
func GetFieldByStruct ¶
GetFieldByStruct 获取结构体字段
func GetIpV6AreaFromUrl ¶
GetIpV6AreaFromUrl 从url当中得到ipv6结果
func GetTimeByUnixMicro ¶
GetTimeByUnixMicro 通过unix获取时间 - 微秒
func GetUnixMicroByDateTime ¶
GetUnixMicroByDateTime GetTimeByDateTime 通过时间获取时间
func InSlice ¶
func InSlice[T int8 | uint8 | int16 | uint16 | int32 | uint32 | int | uint | int64 | uint64 | float32 | float64 | string | bool](arr []T, ele T) bool
InSlice 字符串序列是否包含
func MessageChannel ¶
MessageChannel 首选短信通道
func MessageChannelSecond ¶
MessageChannelSecond 次用短信通道
func MessageChannelSpare ¶
MessageChannelSpare 备用短信通道
func SetStructFieldByJsonName ¶
SetStructFieldByJsonName 将hgetall出来的map[string]string转换成对应的结构体
func StructureToMap ¶
StructureToMap 结构转map,因为struct不能循环,map可以.
func StructureToMapNew ¶
func StructureToMapNew(item interface{}) map[string]interface{}
StructureToMapNew 结构转map,因为struct不能循环,map可以.
func StructureToSlice ¶
StructureToSlice 结构转map,因为struct不能循环,map可以.
Types ¶
type ZxincV6 ¶
type ZxincV6 struct {
Code int `json:"code"`
Data struct {
Country string `json:"country"`
Ip struct {
End string `json:"end"`
Start string `json:"start"`
} `json:"ip"`
Local string `json:"local"`
Location string `json:"location"`
Myip string `json:"myip"`
} `json:"data"`
}
ZxincV6 从zxinc网址拿来下的数据结构