value

package
v0.1.140 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(data interface{}, ptr interface{})

Decode data bytes to ptr

func Encode

func Encode(data interface{}) []byte

Encode encode data to bytes

Types

type Value

type Value struct {
	// contains filtered or unexported fields
}

Value adapter for value of any type, provide uniform encoding and decoding.

func New

func New(data interface{}) *Value

func (*Value) Bool

func (v *Value) Bool() bool

Bool return underlying data as bool

func (*Value) Bytes

func (v *Value) Bytes() []byte

Bytes return underlying data as bytes

func (*Value) Data

func (v *Value) Data() interface{}

Data return underlying data

func (*Value) Decode

func (v *Value) Decode(ptr interface{})

Decode decode data bytes to ptr, panic if failed

func (*Value) Encode

func (v *Value) Encode() []byte

Encode encode data to bytes, panic if failed

func (*Value) Float

func (v *Value) Float() float64

Float return underlying data as float64

func (*Value) Int

func (v *Value) Int() int

Int return underlying data as int

func (*Value) MarshalJSON

func (v *Value) MarshalJSON() ([]byte, error)

func (*Value) String

func (v *Value) String() string

String return underlying data as string

func (*Value) TryDecode

func (v *Value) TryDecode(ptr interface{}) (err error)

TryDecode try decode data, err is not nil if panic

func (*Value) TryEncode

func (v *Value) TryEncode() (output []byte, err error)

TryEncode try encode data, err is not nil if panic

func (*Value) UnmarshalJSON

func (v *Value) UnmarshalJSON(b []byte) error

func (*Value) Valid

func (v *Value) Valid() bool

Valid check the underlying data is nil

Jump to

Keyboard shortcuts

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