utils

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StringType = "string"
	NumberType = "number"
	BoolType   = "bool"
	Unknown    = "unknown"
)
View Source
const (
	Seconds = "seconds"
	Minutes = "minutes"
	Hours   = "hours"
)

Variables

This section is empty.

Functions

func ConvertArrToMap

func ConvertArrToMap(list []string) map[string]bool

func ConvertBool

func ConvertBool(obj interface{}) (bool, bool)

func ConvertDataType

func ConvertDataType(obj interface{}, dataType string) (interface{}, error)

func ConvertFloat64

func ConvertFloat64(obj interface{}) (float64, bool)

func ConvertInt64

func ConvertInt64(obj interface{}) (int64, bool)

func ConvertMSToUnit

func ConvertMSToUnit(t int64) (value int64, unit string)

func ConvertString

func ConvertString(obj interface{}) (string, bool)

func ConvertStringArr

func ConvertStringArr(obj interface{}) ([]string, bool)

ConvertStringArr interface转字符串数组

func ConvertStringArrToInterfaceArr

func ConvertStringArrToInterfaceArr(list []string) []interface{}

func ConvertStringToMS

func ConvertStringToMS(value string, now int64) (int64, error)

func ConvertStructToMap

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

func ConvertTimeToMS

func ConvertTimeToMS(t time.Time) int64

func ConvertUint64

func ConvertUint64(obj interface{}) (uint64, bool)

func ConvertUnitToMS

func ConvertUnitToMS(value int64, unit string) int64

func GetMapValue

func GetMapValue(key string, data map[string]interface{}) interface{}

func GetMapValueArr

func GetMapValueArr(m map[string]interface{}, key string) ([]interface{}, bool)

func GetMapValueBool

func GetMapValueBool(m map[string]interface{}, key string) (bool, bool)

func GetMapValueFloat64

func GetMapValueFloat64(m map[string]interface{}, key string) (float64, bool)

func GetMapValueInt64

func GetMapValueInt64(m map[string]interface{}, key string) (int64, bool)

func GetMapValueMap

func GetMapValueMap(m map[string]interface{}, key string) (map[string]interface{}, bool)

func GetMapValueString

func GetMapValueString(m map[string]interface{}, key string) (string, bool)

func GetMapValueUint64

func GetMapValueUint64(m map[string]interface{}, key string) (uint64, bool)

func NewContextWithHeader added in v1.1.0

func NewContextWithHeader(ctx context.Context) context.Context

func RandomString

func RandomString(n int) string

func TypeOf

func TypeOf(obj interface{}) string

Types

type Duration

type Duration time.Duration

func (Duration) Duration

func (d Duration) Duration() time.Duration

func (Duration) FormatDuration

func (d Duration) FormatDuration(precision int) (string, error)

Keep the specified decimal places.

func (Duration) MarshalYAML

func (d Duration) MarshalYAML() (interface{}, error)

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error

Jump to

Keyboard shortcuts

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