tool

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: Apache-2.0 Imports: 28 Imported by: 1

Documentation

Index

Constants

View Source
const (
	GET    = "GET"
	PUT    = "PUT"
	POST   = "POST"
	DELETE = "DELETE"
)
View Source
const (
	ContentType               = "Content-Type"
	ApplicationJson           = "application/json"
	ApplicationFromUrlencoded = "application/x-www-from-urlencoded"
)

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 DurationToDateTime

func DurationToDateTime(timeData uint64) time.Time

func EntryIdToString

func EntryIdToString(id cron.EntryID) string

EntryIdToString EntryID转string

func FloatConv

func FloatConv(num float64) float64

func GetACHttpRequest

func GetACHttpRequest() *resty.Request

func GetDirSize

func GetDirSize(path string) (int64, error)

DirSize 获取整体文件夹大小

func GetGVR

GetGVR 获取GVR

func GetTimeDurationString

func GetTimeDurationString(startTime string, endTime string) string

func HttpClient

func HttpClient(method string, url string, payload io.Reader, token string) ([]byte, error)

func HttpClientStatusCode

func HttpClientStatusCode(method string, url string, payload io.Reader, token string) (int, error)

func HttpClientWithBodyAndCode

func HttpClientWithBodyAndCode(method string, url string, payload io.Reader, token string) (int, []byte, error)

func HttpClientWithQueries

func HttpClientWithQueries[T any](method string, url string, payload io.Reader, token string, param T) ([]byte, error)

func HttpClientWithScreen

func HttpClientWithScreen(method string, url string, payload io.Reader) (int, []byte, error)

func HttpGet

func HttpGet(method string, url string) ([]byte, error)

func HttpPost

func HttpPost(url string, data interface{}) (content string, err error)

发送POST请求 url:请求地址,data:POST请求提交的数据,contentType:请求体格式,如:application/json content:请求放回的内容

func Int64ToString

func Int64ToString(value int64) string

Int64ToString int64转string

func K8sUnstructured

func K8sUnstructured(dataString string, target interface{})

func NewHttpsClient

func NewHttpsClient() *resty.Client

func PathExists

func PathExists(path string) (bool, error)

PathExists 判断文件夹是否存在

func RemoveDuplication_map

func RemoveDuplication_map(arr []string) []string

removeDuplication_map 去重数组

func RunTimeToSeconds

func RunTimeToSeconds(runTime string) int

func StringToInt

func StringToInt(value string) int

func TimeRemoveZone

func TimeRemoveZone(tm time.Time) time.Time

func TimeStringRemoveZone

func TimeStringRemoveZone(tm string) string

func TimeStringToGoTime

func TimeStringToGoTime(tm string) time.Time

TimeStringToGoTime 时间格式字符串转换

func UnMarshalK8sStruct

func UnMarshalK8sStruct(yamlString string, taskId int64) model.Cloud

func Yaml2struct

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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