convert

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Overview

This package contains helper functions for that are related to converting interfaces to other types and checking the type of an interface

This package contains helper functions for that are related to converting interfaces to other types and checking the type of an interface

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetType

func GetType(value interface{}) string

GetType will return the type of the value as a string - value: the value to get the type of - returns: the type of the value as a string

func IsBool added in v0.2.2

func IsBool(value interface{}) bool

IsBool takes an interface and returns true if the interface is a bool - value: the interface to check - returns: true if the interface is a bool

func IsFloat added in v0.2.2

func IsFloat(value interface{}) bool

IsFloat takes an interface and returns true if the interface is a float - value: the interface to check - returns: true if the interface is a float

func IsInt added in v0.2.2

func IsInt(value interface{}) bool

IsInt takes an interface and returns true if the interface is an int - value: the interface to check - returns: true if the interface is an int

func IsMapInterface added in v0.2.2

func IsMapInterface(value interface{}) bool

IsMapInterface takes an interface and returns true if the interface is a map[string]interface{} - value: the interface to check - returns: true if the interface is a map[string]interface{}

func IsString added in v0.2.2

func IsString(value interface{}) bool

IsString takes an interface and returns true if the interface is a string - value: the interface to check - returns: true if the interface is a string

func ToArrayBool

func ToArrayBool(value interface{}) []bool

ToArrayBool will convert the interface of an array to an array of bools - value: the value to convert - returns: an array of bools

func ToArrayFloat32

func ToArrayFloat32(value interface{}) []float32

ToArrayFloat32 will convert the interface of an array to an array of float32s - value: the value to convert - returns: an array of float32s

func ToArrayFloat64

func ToArrayFloat64(value interface{}) []float64

ToArrayFloat64 will convert the interface of an array to an array of float64s - value: the value to convert - returns: an array of float64s

func ToArrayInt

func ToArrayInt(value interface{}) []int

ToArrayInt will convert the interface of an array to an array of ints - value: the value to convert - returns: an array of ints

func ToArrayInterface

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

ToArrayInterface will convert the interface of an array to an array of interfaces - value: the value to convert - returns: an array of interfaces

func ToArrayString

func ToArrayString(value interface{}) []string

ToArrayString will convert the interface of an array to an array of strings - value: the value to convert - returns: an array of strings

func ToBool

func ToBool(value interface{}) bool

If the value is a string, it will return true if the string is "t", "true", "yes", "y", "1", "pass", or "0". Otherwise, it will return false - value: the value to convert - returns: a boolean value

func ToFloat32

func ToFloat32(value interface{}) float32

ToFloat32 will convert the value to a float32 - value: the value to convert - returns: a float32 value

func ToFloat64

func ToFloat64(value interface{}) float64

ToFloat64 will convert the value to a float64 - value: the value to convert - returns: a float64 value

func ToInt

func ToInt(value interface{}) int

ToInt will convert the value to an int - value: the value to convert - returns: an int value

func ToInt32

func ToInt32(value interface{}) int32

ToInt32 will convert the value to an int32 - value: the value to convert - returns: an int32 value

func ToInt64

func ToInt64(value interface{}) int64

ToInt64 will convert the value to an int64 - value: the value to convert - returns: an int64 value

func ToInt8

func ToInt8(value interface{}) int8

ToInt8 will convert the value to an int8 - value: the value to convert - returns: an int8 value

func ToMapFloat32

func ToMapFloat32(value interface{}) map[string]float32

ToMapFloat32 will convert the interface of a map to a map of float32s - value: the value to convert - returns: a map of float32s

func ToMapFloat64

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

ToMapFloat64 will convert the interface of a map to a map of float64s - value: the value to convert - returns: a map of float64s

func ToMapInt

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

ToMapInt will convert the interface of a map to a map of ints - value: the value to convert - returns: a map of ints

func ToMapInterface

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

ToMapInterface will convert the interface of a map to a map of interfaces - value: the value to convert - returns: a map of interfaces

func ToMapString

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

ToMapString will convert the interface of a map to a map of strings - value: the value to convert - returns: a map of strings

func ToPassFail

func ToPassFail(value bool) string

`ToPassFail` takes a boolean value and returns a string value of either "Pass" or "Fail" depending on the boolean value - value: the boolean value to convert - returns: a string value of either "Pass" or "Fail"

func ToString

func ToString(value interface{}) string

ToString will convert the value to a string - value: the value to convert - returns: a string value

Types

This section is empty.

Jump to

Keyboard shortcuts

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