dict

package
v0.10.4 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dict

type Dict map[string]interface{}

Dict is a pass-through implementation of the Dicter interface

func (Dict) Bool

func (d Dict) Bool(key string, def *bool) (r bool, err error)

func (Dict) BoolSlice

func (d Dict) BoolSlice(key string) (r []bool, err error)

func (Dict) Float

func (d Dict) Float(key string, def *float64) (r float64, err error)

func (Dict) FloatSlice

func (d Dict) FloatSlice(key string) (r []float64, err error)

func (Dict) Int

func (d Dict) Int(key string, def *int) (r int, err error)

func (Dict) IntSlice

func (d Dict) IntSlice(key string) (r []int, err error)

func (Dict) Interface

func (d Dict) Interface(key string) (r interface{}, ok bool)

func (Dict) Map

func (d Dict) Map(key string) (r Dicter, err error)

func (Dict) MapSlice

func (d Dict) MapSlice(key string) (r []Dicter, err error)

func (Dict) String

func (d Dict) String(key string, def *string) (r string, err error)

func (Dict) StringSlice

func (d Dict) StringSlice(key string) (r []string, err error)

func (Dict) Uint

func (d Dict) Uint(key string, def *uint) (r uint, err error)

func (Dict) UintSlice

func (d Dict) UintSlice(key string) (r []uint, err error)

type Dicter

type Dicter interface {
	String(key string, Default *string) (string, error)
	StringSlice(key string) ([]string, error)

	Bool(key string, Default *bool) (bool, error)
	BoolSlice(key string) ([]bool, error)

	Int(key string, Default *int) (int, error)
	IntSlice(key string) ([]int, error)

	Uint(key string, Default *uint) (uint, error)
	UintSlice(key string) ([]uint, error)

	Float(key string, Default *float64) (float64, error)
	FloatSlice(key string) ([]float64, error)

	Map(key string) (Dicter, error)
	MapSlice(key string) ([]Dicter, error)

	Interface(key string) (v interface{}, ok bool)
}

Dicter is an abstraction over map[string]interface{} with the intent of allowing manipulation between the underlying data and requests for that data.

type ErrKeyRequired

type ErrKeyRequired string

ErrKeyRequired is used to communicate a map miss and Dicter implementations should set the value as the missed key

func (ErrKeyRequired) Error

func (err ErrKeyRequired) Error() string

type ErrKeyType

type ErrKeyType struct {
	Key   string
	Value interface{}
	T     reflect.Type
}

ErrKeyType is used to communicate the value requested cannot be converted/coerced/manipulated according to the method call. TODO: rename to ErrType

func (ErrKeyType) Error

func (err ErrKeyType) Error() string

Jump to

Keyboard shortcuts

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