package module
Version: v0.0.0-...-fbd2a32 Latest Latest

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

Go to latest
Published: Feb 18, 2019 License: MIT Imports: 5 Imported by: 0



Util functions for Golang




This section is empty.


This section is empty.


func Cast2Bool

func Cast2Bool(v interface{}) bool

func Cast2Float32

func Cast2Float32(v interface{}) float32

func Cast2Float64

func Cast2Float64(v interface{}) float64

func Cast2Int

func Cast2Int(v interface{}) int

func Cast2String

func Cast2String(v interface{}) string

func CastPrimitiveSlice

func CastPrimitiveSlice(items []interface{}, t reflect.Kind) interface{}

func CastPrimitiveSliceInplace

func CastPrimitiveSliceInplace(items *[]interface{}, t reflect.Kind)

func CastPrimitiveValueInplace

func CastPrimitiveValueInplace(item *interface{}, t reflect.Kind)

todo: support more type

func GetEnvOrDefault

func GetEnvOrDefault(k string, dv interface{}) interface{}

k, env name for `os.LookupEnv` call dv, for default return value. some advices(or say notices) may be helpful: 1. if do not care default value, you can just pass `nil`, and the function's behavior is just like `os.GetEnv` 2. if you do known or do need that the type of returned value is specified, you can pass the `zero-value` of this type, like "" for string, 0 for int 3. if dv is not `nil`, and the env variable found, will cast the env variable from string type to dv's type

func InterfaceHasNilValue

func InterfaceHasNilValue(actual interface{}) bool

func PanicError

func PanicError(err error)

func ToBools

func ToBools(items []interface{}) []bool

func ToFloat64s

func ToFloat64s(items []interface{}) []float64

func ToInt64s

func ToInt64s(items []interface{}) []int64

func ToInts

func ToInts(items []interface{}) []int

func ToStrings

func ToStrings(items []interface{}) []string

func TransferInterfaceLike

func TransferInterfaceLike(v unsafe.Pointer, dv interface{})


This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL