lang

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2021 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolPointer

func BoolPointer(value bool) *bool

BoolPointer convert a bool to pointer

func Float64Of

func Float64Of(unknown interface{}) (float64, error)

Float64Of try to get an float64 of unknown type

func HashOf

func HashOf(value string) uint32

HashOf calculate uint32 hash code of a string

func Int64Of

func Int64Of(unknown interface{}) (int64, error)

Int64Of try to get an int64 of unknown type

func IntOf

func IntOf(unknown interface{}) (int, error)

IntOf try to get an int64 of unknown type

func IsEmptyString

func IsEmptyString(s *string) bool

IsEmptyString true if given string is nil or empty

func StringArrayOf

func StringArrayOf(unknown interface{}) ([]string, error)

StringArrayOf try to convert an unknown to string array

func StringLastOf

func StringLastOf(unknown interface{}, count int) string

StringLastOf try to get last $count of characters from an unknown

func StringOf

func StringOf(unknown interface{}) string

StringOf try to get a string of unknown type

func StringRandom

func StringRandom(size int) string

StringRandom random string with size given

func StringSliceContains added in v2.0.1

func StringSliceContains(slices []string, value string) bool

func ToDurationPtr

func ToDurationPtr(d time.Duration) *time.Duration

ToDurationPtr convert a time.Duration to a pointer

func Uint64Of

func Uint64Of(unknown interface{}) (uint64, error)

Uint64Of try to get an uint64 of unknown type

Types

type IMapDecoder

type IMapDecoder interface {
	Decode(in interface{}, out interface{}) error
}

IMapDecoder map decoder interface

type JSONMapDecoder

type JSONMapDecoder struct {
}

JSONMapDecoder decode map to an object

func (*JSONMapDecoder) Decode

func (d *JSONMapDecoder) Decode(in interface{}, out interface{}) error

Decode in into out

type StringMap

type StringMap map[string]interface{}

StringMap with additional functions

func (*StringMap) Get

func (m *StringMap) Get(key string) (interface{}, bool)

Get value by key

func (*StringMap) GetAs

func (m *StringMap) GetAs(key string, out interface{}) error

GetAs decode using json

func (*StringMap) GetAsByPath

func (m *StringMap) GetAsByPath(path string, out interface{}) error

GetAsByPath Get a value with dot-separated path

func (*StringMap) GetAsWith

func (m *StringMap) GetAsWith(decoder IMapDecoder, key string, out interface{}) error

GetAsWith given decoder

func (*StringMap) Set

func (m *StringMap) Set(key string, value interface{})

Set key = value

Jump to

Keyboard shortcuts

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