utils

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LarkMsgType_Text       = "text"        //富文本
	LarkMsgType_Post       = "post"        //富文本
	LarkMsgType_Image      = "image"       //图片
	LarkMsgTyp_ShareChat   = "share_chat"  //分享群名片
	LarkMsgTyp_Interactive = "interactive" //消息卡片
)
View Source
const AesKeyPepper = "bridgx"
View Source
const DefaultKey = "schedulx"

Variables

View Source
var (
	ErrEncryptFailed = errors.New("encrypt failed")
	ErrDecryptFailed = errors.New("decrypt failed")
)

Functions

func AESDecrypt added in v0.7.0

func AESDecrypt(key string, ct16 string) (text string, err error)

func AESEncrypt added in v0.7.0

func AESEncrypt(key, plaintext string) (text string, err error)

func AesDecrypt added in v0.7.0

func AesDecrypt(cryptedBase64 string, key []byte) ([]byte, error)

func AesEncrypt added in v0.7.0

func AesEncrypt(origData, key []byte) (string, error)

func Base64Md5

func Base64Md5(params string) string

func CurrentTZTime added in v0.4.0

func CurrentTZTime() string

func CurrentTime

func CurrentTime() string

func Filter added in v0.2.1

func Filter(source []int64, filter func(int64) bool) []int64

func FormatTime added in v0.4.0

func FormatTime(t time.Time) string

func GetNextId added in v0.7.0

func GetNextId() uint64

func GetProjectPath

func GetProjectPath() string

func HttpGetT

func HttpGetT(addr string, timeout int) (ret []byte, err error)

带超时的http get

func HttpPostJsonDataT

func HttpPostJsonDataT(addr string, jsonDataBytes []byte, timeout int) (ret []byte, err error)

HttpPostJsonDataT 带超时的http post json string as data

func HttpPostT

func HttpPostT(ctx context.Context, addr string, data url.Values, timeout int) (ret []byte, err error)

HttpPostT 带超时的http post

func Int added in v0.5.0

func Int(a int) *int

func Int16 added in v0.5.0

func Int16(a int16) *int16

func Int16Value added in v0.5.0

func Int16Value(a *int16) int16

func Int32 added in v0.5.0

func Int32(a int32) *int32

func Int32Value added in v0.5.0

func Int32Value(a *int32) int32

func Int63nRange added in v0.7.0

func Int63nRange(min, max int64) int64

func Int64 added in v0.5.0

func Int64(a int64) *int64

func Int64Value added in v0.5.0

func Int64Value(a *int64) int64

func Int8 added in v0.5.0

func Int8(a int8) *int8

func Int8Value added in v0.5.0

func Int8Value(a *int8) int8

func IntValue added in v0.5.0

func IntValue(a *int) int

func Interface2Int64

func Interface2Int64(inter interface{}) int64

func Interface2String

func Interface2String(value interface{}) string

func Intersect added in v0.7.0

func Intersect(lists [][]string) []string

多个切片求交集

func IsPrivateIPv4

func IsPrivateIPv4(ip net.IP) bool

func IsProd

func IsProd() bool

func LarkAlarm

func LarkAlarm(ctx context.Context, hookID string, title string, text string) (err error)

func LarkAlarmBase

func LarkAlarmBase(ctx context.Context, hookID string, title string, text string) (err error)

func LocalIp

func LocalIp() (string, error)

func MD5

func MD5(params string) string

func ObjToJson

func ObjToJson(obj interface{}) string

func PKCS5Padding added in v0.7.0

func PKCS5Padding(plaintext []byte, blockSize int) []byte

func PKCS5UnPadding added in v0.7.0

func PKCS5UnPadding(origData []byte) []byte

func ParseTime added in v0.4.0

func ParseTime(value string) time.Time

func ParseTimeInLocation added in v0.4.0

func ParseTimeInLocation(value string, loc *time.Location) time.Time

func ParseTimeTz added in v0.4.0

func ParseTimeTz(value string) time.Time

func ParseTimeTzInLocation added in v0.4.0

func ParseTimeTzInLocation(value string, loc *time.Location) time.Time

func PrivateIPv4

func PrivateIPv4() string

func RandomInt

func RandomInt(min, max int) int64

RandomInt returns, as an int64, a negative pseudo-random number in [min,max]

func SliceToStringSet

func SliceToStringSet(s []string) *hashset.Set

func SshCheck added in v0.4.0

func SshCheck(ip, user, pwd string) bool

SshCheck 测试目的机器SSH连通性

func String added in v0.5.0

func String(a string) *string

func StringSliceDiff added in v0.7.0

func StringSliceDiff(s1, s2 []string) []string

StringSliceDiff s1-s2

func StringSliceSplit

func StringSliceSplit(slice []string, singleLen int64) [][]string

func StringValue added in v0.5.0

func StringValue(a *string) string

func ToInt64SliceE

func ToInt64SliceE(i interface{}) ([]int64, error)

func ToStringSet

func ToStringSet(s string) *hashset.Set

Types

type LarkMsgResponse

type LarkMsgResponse struct {
	Code          int64  `json:"code"`
	Msg           string `json:"msg"`
	StatusCode    int64  `json:"StatusCode"`
	StatusMessage string `json:"StatusMessage"`
}

// err response

{
    "code": 19002,
    "msg": "params error, msg_type need"
}

// success response

{
    "Extra": null,
    "StatusCode": 0,
    "StatusMessage": "success"
}

Jump to

Keyboard shortcuts

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