parser

package
v0.0.0-...-39fcf47 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNil = errors.New("nil returned")

ErrNil indicates that a data value is nil.

Functions

func Bool

func Bool(data interface{}, err error) (bool, error)

Bool is a helper that converts a command data to a boolean. If err is not equal to nil, then Bool returns false, err. Otherwise Bool converts the data to boolean as follows:

Reply type      Result
integer         value != 0, nil
bulk string     strconv.ParseBool(data)
nil             false, ErrNil
other           false, error

func Float64

func Float64(data interface{}, err error) (float64, error)

Float64 is a helper that converts a command data to 64 bit float. If err is not equal to nil, then Float64 returns 0, err. Otherwise, Float64 converts the data to an int as follows:

Reply type    Result
bulk string   parsed data, nil
nil           0, ErrNil
other         0, error

func Int

func Int(data interface{}, err error) (int, error)

Int is a helper that converts a command data to an integer. If err is not equal to nil, then Int returns 0, err. Otherwise, Int converts the data to an int as follows:

Reply type    Result
integer       int(data), nil
bulk string   parsed data, nil
nil           0, ErrNil
other         0, error

func Int64

func Int64(data interface{}, err error) (int64, error)

Int64 is a helper that converts a command data to 64 bit integer. If err is not equal to nil, then Int returns 0, err. Otherwise, Int64 converts the data to an int64 as follows:

Reply type    Result
integer       data, nil
bulk string   parsed data, nil
nil           0, ErrNil
other         0, error

func String

func String(data interface{}, err error) (string, error)

String is a helper that converts a command data to a string. If err is not equal to nil, then String returns "", err. Otherwise String converts the data to a string as follows:

Reply type      Result
bulk string     string(data), nil
simple string   data, nil
nil             "",  ErrNil
other           "",  error

func Strings

func Strings(data interface{}, err error) ([]string, error)

Strings is a helper that converts an array command data to a []string. If err is not equal to nil, then Strings returns nil, err. Nil array items are converted to "" in the output slice. Strings returns an error if an array item is not a bulk string or nil.

Types

type Error

type Error string

Error represents an error returned in a command data.

func (Error) Error

func (err Error) Error() string

Jump to

Keyboard shortcuts

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