utils

package
v1.5.8 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Layout1                 = "2006-01-02T15:04:05.000Z"
	UTC8Layout              = "2006.01.02 15:04:05-0700"
	YYYY_MM_DD_Layout       = "2006-01-02"
	YYYYmmddHHMMSSLayout    = "20060102150405"
	YYYY_mm_dd_HHMMSSLayout = "2006-01-02 15:04:05"
)

Variables

This section is empty.

Functions

func AesDecrypt

func AesDecrypt(cryted string, key string) string

AesDecrypt 解密

func AesEncrypt

func AesEncrypt(orig string, key string) string

AesEncrypt 加密 key 的长度最少为16位 最好是16/24/32 位

func Base64Decode

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

Base64Decode base64 解密

func Base64Encode

func Base64Encode(src []byte) string

Base64Encode base64 加密

func BitToMb

func BitToMb(b int64) int64

func CreateUUID

func CreateUUID() string

func CstTimeToTimestampUnix

func CstTimeToTimestampUnix(value string) (int64, error)

CstTimeToTimestampUnix 2006-01-02 15:04:05 类型的 字符串转换成 timestamp, 从 1790 timestamp 是指格林威治时间1970年01月01日00时00分00秒 (北京时间1970年01月01日08时00分00秒)起至现在的总秒数。 时间需要是 UTC 时间

func CstTimeToTimestampUnixMilli

func CstTimeToTimestampUnixMilli(value string) (int64, error)

CstTimeToTimestampUnixMilli 时间戳转化为 时间字符串 转化后的格式为 2006-01-02 15:04:05 2006-01-02 15:04:05 类型的 字符串转换成 timestamp 毫秒数 时间需要是 CTS 时间 , UTC+8的时间

func FileExists

func FileExists(path string) bool

FileExists 判断文件是否存在

func GenerateUuid

func GenerateUuid() string

GenerateUuid 生成8位由数字字母组成的字符串

func GetAllFile

func GetAllFile(pathname string, s []string) ([]string, error)

GetAllFile 遍历文件夹获取所有文件

func HourToFullFmt

func HourToFullFmt(timeStr string) (string, error)

HourToFullFmt 输入: 15:04 要求输出 : 2006-01-02T15:04:05.000Z

func InSlice

func InSlice(key interface{}, slice interface{}) bool

func MapSliceToStructSlice

func MapSliceToStructSlice(maps []map[string]interface{}, outSlice interface{}) error

MapSliceToStructSlice 将 []map 转换为 []struct,并直接修改传入的切片

func MapToStruct

func MapToStruct(m map[string]interface{}, obj interface{}) error

MapToStruct 将单个 map 转换为 struct

func NowUtc

func NowUtc() string

NowUtc 当前 UTC 时间的字符串 2006.01.02 15:04:05-0700

func PKCS7Padding

func PKCS7Padding(ciphertext []byte, blocksize int) []byte

PKCS7Padding 补码

func PKCS7UnPadding

func PKCS7UnPadding(origData []byte) []byte

PKCS7UnPadding 去码

func ReadFromFile

func ReadFromFile(filename string) (string, error)

func RemoveRepByMap

func RemoveRepByMap(slc []string) []string

RemoveRepByMap slice去重

func SendDingTalkActionCard added in v1.5.5

func SendDingTalkActionCard(webhook string, actionCard DingTalkActionCard, at []string, isAtAll bool) error

func SendDingTalkMessage added in v1.5.5

func SendDingTalkMessage(webhook string, content string, at []string, isAtAll bool) error

func TimeParseYYYYMMDD

func TimeParseYYYYMMDD(value string) (time.Time, error)

TimeParseYYYYMMDD 2006-01-02 类型的 字符串转换成 time.TIme

func TimeToTimestampUnix

func TimeToTimestampUnix(value string) (int64, error)

TimeToTimestampUnix 2006-01-02 15:04:05 类型的 字符串转换成 timestamp, 从 1790 timestamp 是指格林威治时间1970年01月01日00时00分00秒 (北京时间1970年01月01日08时00分00秒)起至现在的总秒数。 时间需要是 UTC 时间

func TimeToTimestampUnixMilli

func TimeToTimestampUnixMilli(value string) (int64, error)

TimeToTimestampUnixMilli 2006-01-02 15:04:05 类型的 字符串转换成 timestamp 毫秒数 时间需要是 UTC 时间

func TimeparseyyyyMmDdHhmmsslayout

func TimeparseyyyyMmDdHhmmsslayout(value string) (time.Time, error)

TimeparseyyyyMmDdHhmmsslayout 2006-01-02 15:04:05 类型的 字符串转换成 time.TIme 时间需要是Utc 时间

func TimestampToTime

func TimestampToTime(value int64) time.Time

TimestampToTime 时间戳转化为时间 time.Time

func WriteLinesToFile

func WriteLinesToFile(filename, content string, _append bool) error

func WriteToFile

func WriteToFile(filename, content string) error

WriteToFile 写入文件

Types

type DingTalkActionCard added in v1.5.5

type DingTalkActionCard struct {
	Title          string `json:"title"`
	Text           string `json:"text"`
	BtnOrientation string `json:"btnOrientation"`
	SingleTitle    string `json:"singleTitle"`
	SingleURL      string `json:"singleURL"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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