utils

package
v0.0.0-...-549fefd Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Converters = []copier.TypeConverter{
	{
		SrcType: time.Time{},
		DstType: copier.String,
		Fn: func(src interface{}) (interface{}, error) {
			s, ok := src.(time.Time)

			if !ok {
				return nil, errors.New("src type not matching")
			}

			return s.Format(time.RFC3339), nil
		},
	},
	{
		SrcType: copier.String,
		DstType: copier.Int,
		Fn: func(src interface{}) (interface{}, error) {
			s, ok := src.(string)

			if !ok {
				return nil, errors.New("src type not matching")
			}

			return strconv.Atoi(s)
		},
	},
	{
		SrcType: copier.String,
		DstType: copier.Bool,
		Fn: func(src interface{}) (interface{}, error) {
			s, ok := src.(string)

			if !ok {
				return nil, errors.New("src type not matching")
			}

			return strconv.ParseBool(s)
		},
	},
}

Functions

func Convert

func Convert(source interface{}, target interface{})

Convert 通过JSON赋值

func ConvertStructToMap

func ConvertStructToMap(in interface{}) map[string]string

func Delete

func Delete(token, endpoint, url string, pathParams *map[string]string, body *string, resultData interface{}) (*resty.Response, error)

Delete 方法

func EntryIdToString

func EntryIdToString(id cron.EntryID) string

EntryIdToString EntryID转string

func FloatConv

func FloatConv(num float64) float64

func GenSnowflakeID

func GenSnowflakeID() int64

GenSnowflakeID 生成雪花算法id machineId 工作id

func Get

func Get(token, endpoint, url string, pathParams *map[string]string, queryParams *map[string]string, resultData interface{}) (*resty.Response, error)

Get 方法

func GetCallFunc

func GetCallFunc() string

获取调用方法

func GetGVR

GetGVR 获取GVR

func GetParticipantId

func GetParticipantId(filePath string) (int64, error)

GetParticipantId 获取本地配置文件中的ParticipantId

func InitSnowflake

func InitSnowflake(machineID int64) (err error)

func Int64ToString

func Int64ToString(value int64) string

Int64ToString int64转string

func K8sUnstructured

func K8sUnstructured(dataString string, target interface{})

func NewRequest

func NewRequest(token string, endpoint string, cli *resty.Client) (*resty.Request, error)

NewRequest 构造一个请求

func Post

func Post(token, endpoint, url string, contentType string,
	pathParams *map[string]string, fileParams *map[string]string, queryParams *map[string]string,
	body *string, formData *map[string]string, resultData interface{}) (*resty.Response, error)

Post

func RandomString

func RandomString(n int) string

func RemoveDuplication_map

func RemoveDuplication_map(arr []string) []string

removeDuplication_map 去重数组

func ResponseWithLog

func ResponseWithLog(ctx *context.Context, funcName string, req *resty.Request, result *resty.Response, err error) (*resty.Response, error)

提取错误信息并记录日志

func RunTimeToSeconds

func RunTimeToSeconds(runTime string) int

func StringToFloat64

func StringToFloat64(value string) float64

func StringToInt

func StringToInt(value string) int

func StringToInt64

func StringToInt64(value string) int64

func UpdateParticipantId

func UpdateParticipantId(filePath string, value string) error

UpdateParticipantId 更新本地配置文件ParticipantId

func Yaml2struct

func Yaml2struct(fileHeader *multipart.FileHeader, req interface{}) error

Types

type Cli

type Cli struct {
	User       string
	Pwd        string
	Addr       string
	Client     *gossh.Client
	Session    *gossh.Session
	LastResult string
}

Cli 连接信息

func (*Cli) Connect

func (c *Cli) Connect() (*Cli, error)

Connect 连接对象

func (Cli) Run

func (c Cli) Run(shell string) (string, error)

Run 执行shell

type PConfig

type PConfig struct {
	ParticipantId int64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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