cast

package
v1.4.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: Apache-2.0 Imports: 10 Imported by: 14

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 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 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{}, _ 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 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 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