complex

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromJSON

func FromJSON(jsonStr string, target interface{})

FromJSON converts JSON string to specified type.

func FromJSONE

func FromJSONE(jsonStr string, target interface{}) error

FromJSONE converts JSON string to specified type with error.

func ToFloat64Map

func ToFloat64Map(value interface{}) map[string]float64

ToFloat64Map converts any type to map[string]float64.

func ToFloat64MapE

func ToFloat64MapE(value interface{}) (map[string]float64, error)

ToFloat64MapE converts any type to map[string]float64 with error.

func ToFloat64Slice

func ToFloat64Slice(value interface{}) []float64

ToFloat64Slice converts any type to []float64.

func ToFloat64SliceE

func ToFloat64SliceE(value interface{}) ([]float64, error)

ToFloat64SliceE converts any type to []float64 with error.

func ToIntMap

func ToIntMap(value interface{}) map[string]int

ToIntMap converts any type to map[string]int.

func ToIntMapE

func ToIntMapE(value interface{}) (map[string]int, error)

ToIntMapE converts any type to map[string]int with error.

func ToIntSlice

func ToIntSlice(value interface{}) []int

ToIntSlice converts any type to []int.

func ToIntSliceE

func ToIntSliceE(value interface{}) ([]int, error)

ToIntSliceE converts any type to []int with error.

func ToJSON

func ToJSON(value interface{}) string

ToJSON converts any type to JSON string.

func ToJSONE

func ToJSONE(value interface{}) (string, error)

ToJSONE converts any type to JSON string with error.

func ToMap

func ToMap(value interface{}) map[string]interface{}

ToMap converts any type to map[string]interface{}.

func ToMapE

func ToMapE(value interface{}) (map[string]interface{}, error)

ToMapE converts any type to map[string]interface{} with error.

func ToMapFromJSON

func ToMapFromJSON(jsonStr string) map[string]interface{}

ToMapFromJSON converts JSON string to map[string]interface{}.

func ToMapFromJSONE

func ToMapFromJSONE(jsonStr string) (map[string]interface{}, error)

ToMapFromJSONE converts JSON string to map[string]interface{} with error.

func ToMapT

func ToMapT[K comparable, V any](value interface{}) map[K]V

ToMapT converts any type to map[K]V. This is a generic version of ToMap that returns a map with key type K and value type V. It uses reflection caching to improve performance for repeated conversions.

Examples:

// Convert to map[string]string
strMap := ToMapT[string, string](value)

// Convert to map[string]int
intMap := ToMapT[string, int](value)

// Convert to map[int]float64
floatMap := ToMapT[int, float64](value)

func ToMapTE

func ToMapTE[K comparable, V any](value interface{}) (map[K]V, error)

ToMapTE converts any type to map[K]V with error. This is a generic version of ToMapE that returns a map with key type K and value type V. It uses reflection caching to improve performance for repeated conversions.

Examples:

// Convert to map[string]string with error handling
strMap, err := ToMapTE[string, string](value)

// Convert to map[string]int with error handling
intMap, err := ToMapTE[string, int](value)

// Convert to map[int]float64 with error handling
floatMap, err := ToMapTE[int, float64](value)

func ToSlice

func ToSlice(value interface{}) []interface{}

ToSlice converts any type to []interface{}.

func ToSliceE

func ToSliceE(value interface{}) ([]interface{}, error)

ToSliceE converts any type to []interface{} with error.

func ToSliceFromJSON

func ToSliceFromJSON(jsonStr string) []interface{}

ToSliceFromJSON converts JSON string to []interface{}.

func ToSliceFromJSONE

func ToSliceFromJSONE(jsonStr string) ([]interface{}, error)

ToSliceFromJSONE converts JSON string to []interface{} with error.

func ToSliceT

func ToSliceT[T any](value interface{}) []T

ToSliceT converts any type to []T. This is a generic version of ToSlice that returns a slice of type T. It uses reflection caching to improve performance for repeated conversions.

Examples:

// Convert to []string
strSlice := ToSliceT[string](value)

// Convert to []int
intSlice := ToSliceT[int](value)

// Convert to []float64
floatSlice := ToSliceT[float64](value)

func ToSliceTE

func ToSliceTE[T any](value interface{}) ([]T, error)

ToSliceTE converts any type to []T with error. This is a generic version of ToSliceE that returns a slice of type T. It uses reflection caching to improve performance for repeated conversions.

Examples:

// Convert to []string with error handling
strSlice, err := ToSliceTE[string](value)

// Convert to []int with error handling
intSlice, err := ToSliceTE[int](value)

// Convert to []float64 with error handling
floatSlice, err := ToSliceTE[float64](value)

func ToStringMap

func ToStringMap(value interface{}) map[string]string

ToStringMap converts any type to map[string]string

func ToStringMapE

func ToStringMapE(value interface{}) (map[string]string, error)

ToStringMapE converts any type to map[string]string with error

func ToStringSlice

func ToStringSlice(value interface{}) []string

ToStringSlice converts any type to []string

func ToStringSliceE

func ToStringSliceE(value interface{}) ([]string, error)

ToStringSliceE converts any type to []string with error

Types

This section is empty.

Jump to

Keyboard shortcuts

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