require

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package require provides convenient type conversions.

Index

Constants

This section is empty.

Variables

Functions

func Bool added in v0.1.7

func Bool(value interface{}) bool

Bool converts the given value to bool. If the value's type is bool returns this value. Otherwise, returns true if the value is not nil.

func Byte

func Byte(num interface{}, defaultValue ...byte) byte

Byte converts the given number or string value to byte. If conversion is not possible returns the given default value or 0 if no default value is specified.

func Float32

func Float32(num interface{}, defaultValue ...float32) float32

Float32 converts the given number or string value to float32. If conversion is not possible returns the given default value or 0 if no default value is specified.

func Float64

func Float64(num interface{}, defaultValue ...float64) float64

Float64 converts the given number or string value to float64. If conversion is not possible returns the given default value or 0 if no default value is specified.

func Int

func Int(num interface{}, defaultValue ...int) int

Int converts the given number or string value to int. If conversion is not possible returns the given default value or 0 if no default value is specified.

func Int32

func Int32(num interface{}, defaultValue ...int32) int32

Int32 converts the given number or string value to int32. If conversion is not possible returns the given default value or 0 if no default value is specified.

func Int64

func Int64(num interface{}, defaultValue ...int64) int64

Int64 converts the given number or string value to int64. If conversion is not possible returns the given default value or 0 if no default value is specified.

func IsNumber

func IsNumber(i interface{}) bool

IsNumber checks if the given value's type is one of the supported number types: byte, int, int32, int64, float32, float64.

func Number

func Number(value interface{}, kind reflect.Kind) interface{}

Number converts the given number value to the given number type. If conversion is not possible returns 0.

func SiMap

func SiMap(i interface{}) map[string]interface{}

SiMap converts the given map value to map[string]interface{}. If the value is map[interface{}]interface{} tries to convert its keys to string. If the conversion is not possible returns an empty map[string]interface{}.

func String

func String(i interface{}, defaultString ...string) string

String returns the given interface{} as string. If the given value is nil returns the given default string or "".

Types

This section is empty.

Jump to

Keyboard shortcuts

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