utils

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: MulanPSL-2.0 Imports: 24 Imported by: 1

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 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 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 RandomString

func RandomString(n int) string

func RemoveDuplication_map

func RemoveDuplication_map(arr []string) []string

removeDuplication_map 去重数组

func RunTimeToSeconds

func RunTimeToSeconds(runTime string) int

func StrToInfo added in v0.1.14

func StrToInfo(val string) *unstructured.Unstructured

func StringToFloat64

func StringToFloat64(value string) float64

func StringToInt

func StringToInt(value string) int

func StringToInt64

func StringToInt64(value string) int64

func StringToYaml added in v0.1.14

func StringToYaml(in string) *string

func UpdateParticipantId

func UpdateParticipantId(filePath string, value string) error

UpdateParticipantId 更新本地配置文件ParticipantId

func Yaml2struct

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

Types

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