cast

package
v2.1.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

View Source
const (
	JSISO   = "2006-01-02T15:04:05.000Z07:00"
	ISO8601 = "2006-01-02T15:04:05"
)

Variables

This section is empty.

Functions

func ConvertArray

func ConvertArray(s []interface{}) []interface{}

func ConvertDuration

func ConvertDuration(s any) (time.Duration, error)

func ConvertMap

func ConvertMap(s map[interface{}]interface{}) map[string]interface{}

func ConvertSlice

func ConvertSlice(v interface{}) []interface{}

func ConvertToInterfaceArr

func ConvertToInterfaceArr(orig map[string]interface{}) map[string]interface{}

func FormatTime

func FormatTime(time time.Time, f string) (string, error)

func GetConfiguredTimeZone

func GetConfiguredTimeZone() *time.Location

func InterfaceToDuration

func InterfaceToDuration(i interface{}) (time.Duration, error)

InterfaceToDuration converts an interface to a time.Duration.

func InterfaceToTime

func InterfaceToTime(i interface{}, format string) (time.Time, error)

func InterfaceToUnixMilli

func InterfaceToUnixMilli(i interface{}, format string) (int64, error)

func JoinHostPortInt

func JoinHostPortInt(host string, port int) string

func MapToStruct

func MapToStruct(input, output interface{}) error

MapToStruct

* Convert a map into a struct. The output parameter must be a pointer to a struct * The struct can have the json metadata

func MapToStructStrict

func MapToStructStrict(input, output interface{}) error

MapToStructStrict

* Convert a map into a struct. The output parameter must be a pointer to a struct * If the input have key/value pair output do not defined, will report error

func MapToSyncMap

func MapToSyncMap(m map[string]interface{}) *sync.Map

func ParseTime

func ParseTime(t string, f string) (_ time.Time, err error)

func ParseTimeByFormats

func ParseTimeByFormats(t string, formats []string) (_ time.Time, err error)

func SetTimeZone

func SetTimeZone(name string) error

func StringToBytes

func StringToBytes(str string) []byte

func SyncMapToMap

func SyncMapToMap(sm *sync.Map) map[string]interface{}

func TimeFromUnixMilli

func TimeFromUnixMilli(t int64) time.Time

func TimeToUnixMilli

func TimeToUnixMilli(time time.Time) int64

func ToBool

func ToBool(input interface{}, sn Strictness) (bool, error)

func ToBoolSlice

func ToBoolSlice(input interface{}, sn Strictness) ([]bool, error)

func ToByteA

func ToByteA(input interface{}, sn Strictness) ([]byte, error)

ToByteA converts to eKuiper internal byte array

func ToBytes

func ToBytes(input interface{}, sn Strictness) ([]byte, error)

func ToBytesSlice

func ToBytesSlice(input interface{}, sn Strictness) ([][]byte, error)

func ToFloat32

func ToFloat32(input interface{}, sn Strictness) (float32, error)

func ToFloat32Slice

func ToFloat32Slice(input interface{}, sn Strictness) ([]float32, error)

func ToFloat64

func ToFloat64(input interface{}, sn Strictness) (float64, error)

func ToFloat64Slice

func ToFloat64Slice(input interface{}, sn Strictness, anc ArrayNilConvert) ([]float64, error)

func ToInt

func ToInt(input interface{}, sn Strictness) (int, error)

func ToInt16

func ToInt16(input interface{}, sn Strictness) (int16, error)

func ToInt32

func ToInt32(input interface{}, sn Strictness) (int32, error)

func ToInt64

func ToInt64(input interface{}, sn Strictness) (int64, error)

func ToInt64Slice

func ToInt64Slice(input interface{}, sn Strictness) ([]int64, error)

func ToInt8

func ToInt8(input interface{}, sn Strictness) (int8, error)

func ToString

func ToString(input interface{}, sn Strictness) (string, error)

func ToStringAlways

func ToStringAlways(input interface{}) string

TODO datetime type

func ToStringMap

func ToStringMap(input interface{}) (map[string]interface{}, error)

func ToStringSlice

func ToStringSlice(input interface{}, sn Strictness) ([]string, error)

func ToTimeDurationHookFunc

func ToTimeDurationHookFunc() mapstructure.DecodeHookFunc

func ToType

func ToType(value interface{}, newType interface{}) (interface{}, bool)

ToType cast value into newType type newType support bigint, float, string, boolean, datetime, bytea

func ToTypedSlice

func ToTypedSlice(input interface{}, conv func(interface{}, Strictness) (interface{}, error), eleType string, sn Strictness) (interface{}, error)

func ToUint16

func ToUint16(i interface{}, sn Strictness) (uint16, error)

func ToUint32

func ToUint32(i interface{}, sn Strictness) (uint32, error)

func ToUint64

func ToUint64(i interface{}, sn Strictness) (uint64, error)

func ToUint64Slice

func ToUint64Slice(input interface{}, sn Strictness) ([]uint64, error)

func ToUint8

func ToUint8(i interface{}, sn Strictness) (uint8, error)

Types

type ArrayNilConvert

type ArrayNilConvert int8
const (
	IGNORE_NIL ArrayNilConvert = iota
	FORCE_CONVERT
)

type DurationConf

type DurationConf time.Duration

func (DurationConf) MarshalJSON

func (d DurationConf) MarshalJSON() ([]byte, error)

func (DurationConf) MarshalYAML

func (d DurationConf) MarshalYAML() (any, error)

func (*DurationConf) UnmarshalJSON

func (dp *DurationConf) UnmarshalJSON(data []byte) error

func (*DurationConf) UnmarshalYAML

func (dp *DurationConf) UnmarshalYAML(unmarshal func(any) error) error

type Strictness

type Strictness int8
const (
	STRICT Strictness = iota
	CONVERT_SAMEKIND
	CONVERT_ALL
)

Jump to

Keyboard shortcuts

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