cast

package
v0.0.0-...-7686319 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: Apache-2.0 Imports: 9 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNegativeNotAllowed = errors.New("unable to cast negative value")

Functions

func B2S

func B2S(b []byte) string

b2s converts byte slice to a string without memory allocation. See https://groups.google.com/forum/#!msg/Golang-Nuts/ENgbUzYvCuU/90yGx7GUAgAJ .

func S2B

func S2B(s string) []byte

s2b converts string to a byte slice without memory allocation.

func ToBool

func ToBool(i interface{}) (bool, error)

ToBool casts an interface to a bool type.

func ToDuration

func ToDuration(i interface{}) (d time.Duration, err error)

ToDuration casts an interface to a time.Duration type.

func ToFloat32

func ToFloat32(i interface{}) (float32, error)

ToFloat32 casts an interface to a float32 type.

func ToFloat64

func ToFloat64(i interface{}) (float64, error)

ToFloat64 casts an interface to a float64 type.

func ToFloat64Slice

func ToFloat64Slice(i interface{}) ([]float64, error)

ToFloat64Slice casts an interface to a []float64 type.

func ToInt

func ToInt(i interface{}) (int, error)

ToInt casts an interface to an int type.

func ToInt16

func ToInt16(i interface{}) (int16, error)

ToInt16 casts an interface to an int16 type.

func ToInt32

func ToInt32(i interface{}) (int32, error)

ToInt32 casts an interface to an int32 type.

func ToInt64

func ToInt64(i interface{}) (int64, error)

ToInt64 casts an interface to an int64 type.

func ToInt8

func ToInt8(i interface{}) (int8, error)

ToInt8E casts an interface to an int8 type.

func ToIntSlice

func ToIntSlice(i interface{}) ([]int, error)

ToIntSlice casts an interface to a []int type.

func ToString

func ToString(i interface{}) (string, error)

ToString casts an interface to a string type.

func ToStringMap

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

ToStringMap casts an interface to a map[string]interface{} type.

func ToStringMapString

func ToStringMapString(i interface{}) (map[string]string, error)

ToStringMapString casts an interface to a map[string]string type.

func ToStringSlice

func ToStringSlice(i interface{}) ([]string, error)

ToStringSlice casts an interface to a []string type.

func ToUint

func ToUint(i interface{}) (uint, error)

ToUint casts an interface to a uint type.

func ToUint16

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

ToUint16 casts an interface to a uint16 type.

func ToUint32

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

ToUint32E casts an interface to a uint32 type.

func ToUint64

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

ToUint64E casts an interface to a uint64 type.

func ToUint8

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

ToUint8E casts an interface to a uint type.

Types

This section is empty.

Jump to

Keyboard shortcuts

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