args

package
v0.0.0-...-e6d4a3c Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package args provides utilities for working with redigo command arguments.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidTypeForOperation = errors.New("invalid type for the operation")
)

Error variables related to Info and associated functions.

Functions

func AppendAsSimpleStrings

func AppendAsSimpleStrings(stringArgs []string, args []interface{}) []string

AppendAsSimpleStrings appends the string form of args to the stringArgs slice. See AsSimpleString for information how conversion is performed.

func AsSimpleString

func AsSimpleString(arg interface{}) string

AsSimpleString converts an argument passed to redigo's Conn.Send() method to a string. Only arguments which are sent as redis strings are converted. For all other argument types, this function returns the empty string ("").

AsSimpleString does not perform recursion and only supports one level of the redis.Argument interface. This allows inlining.

func AsSimpleStrings

func AsSimpleStrings(args []interface{}) []string

AsSimpleStrings converts the elements of args to their string form. See AsSimpleString for information how conversion is performed.

Types

type Info

type Info struct {
	Arg          interface{}
	UnwrappedArg interface{}

	WrappingLevel int
	Type          Type
	// contains filtered or unexported fields
}

func Parse

func Parse(arg interface{}) Info

Parse extracts information about arg and returns an Info structure containing this information.

func (*Info) AppendRedisBytesString

func (i *Info) AppendRedisBytesString(buf []byte) ([]byte, error)

AppendRedisBytesString appends the argument described by i in the form of a byte slice. Depending on the type of i, a conversion might be performed. All conversions match the conversions performed by redigo when writing arguments to the connection.

func (*Info) BoolValue

func (i *Info) BoolValue() bool

func (*Info) BytesValue

func (i *Info) BytesValue() []byte

func (*Info) Complex128Value

func (i *Info) Complex128Value() complex128

func (*Info) ConvertToInt

func (i *Info) ConvertToInt() (int64, error)

ConvertToInt returns the argument described by i in the form of an int64. Depending on the type of i, a conversion might be performed. Any error occuring during conversion is returned.

TODO: Can Nil be converted to an int?

func (*Info) ConvertToRedisBytesString

func (i *Info) ConvertToRedisBytesString() ([]byte, error)

ConvertToRedisBytesString returns the argument described by i in the form of a byte slice. If i is a byte slice, a reference is returned instead of a copy. The returned slice must not be modified to ensure the consistency of i. Depending on the type of i, a conversion might be performed. All conversions match the conversions performed by redigo when writing arguments to the connection.

func (*Info) ConvertToRedisString

func (i *Info) ConvertToRedisString() (string, error)

ConvertToRedisString returns the argument described by i in the form of a string. Depending on the type of i, a conversion might be performed. All conversions match the conversions performed by redigo when writing arguments to the connection.

func (*Info) ConvertToUint

func (i *Info) ConvertToUint() (uint64, error)

ConvertToUint returns the argument described by i in the form of an uint64. Depending on the type of i, a conversion might be performed. Any error occuring during conversion is returned.

TODO: Can Nil be converted to a uint?

func (*Info) EqualEither

func (i *Info) EqualEither(tString string, tBytes []byte) bool

EqualEither checks string equality of i to either tString OR tBytes using whichever matches the type of i.

func (*Info) EqualFoldEither

func (i *Info) EqualFoldEither(tString string, tBytes []byte) bool

EqualEither checks string equality under unicode case folding of i to either tString OR tBytes using whichever matches the type of i.

func (*Info) Float64Value

func (i *Info) Float64Value() float64

func (*Info) Int64Value

func (i *Info) Int64Value() int64

func (*Info) IsStringLike

func (i *Info) IsStringLike() bool

IsStringLike returns true iff i describes either a String or Bytes argument.

func (*Info) IsWrapped

func (i *Info) IsWrapped() bool

IsWrapped returns true iff i describes an argument wrapped in redis.Argument at least once.

func (*Info) StringValue

func (i *Info) StringValue() string

func (*Info) Uint64Value

func (i *Info) Uint64Value() uint64

type Type

type Type int8
const (
	TypeUnset Type = iota
	TypeString
	TypeBytes
	TypeInt
	TypeUint
	TypeFloat
	TypeBool
	TypeComplex
	TypeNil
)

Jump to

Keyboard shortcuts

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