Documentation ¶
Index ¶
- func Backoff(min, max time.Duration, factor float64, attempt int) time.Duration
- func Contains(list []string, str string) bool
- func Get(acc Accessible, name string) (interface{}, bool)
- func GetBSONKey(field *reflect.StructField) string
- func GetJSONKey(field *reflect.StructField) string
- func Includes(all, subset []string) bool
- func Intersect(listA, listB []string) []string
- func MustGet(acc Accessible, name string) interface{}
- func MustSet(acc Accessible, name string, value interface{})
- func Set(acc Accessible, name string, value interface{}) bool
- func Union(listA, listB []string) []string
- func Unique(list []string) []string
- type Accessible
- type Accessor
- type Coding
- type Field
- type Map
- type NoValidation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Get ¶
func Get(acc Accessible, name string) (interface{}, bool)
Get will lookup the specified field on the accessible and return its value and whether the field was found at all.
func GetBSONKey ¶
func GetBSONKey(field *reflect.StructField) string
GetBSONKey will return the BSON key for the specified struct field.
func GetJSONKey ¶
func GetJSONKey(field *reflect.StructField) string
GetJSONKey will return the JSON key for the specified struct field.
func MustGet ¶
func MustGet(acc Accessible, name string) interface{}
MustGet will call Get and panic if the operation failed.
func MustSet ¶
func MustSet(acc Accessible, name string, value interface{})
MustSet will call Set and panic if the operation failed.
func Set ¶
func Set(acc Accessible, name string, value interface{}) bool
Set will set the specified field on the accessible with the provided value and return whether the field has been found and the value has been set.
Types ¶
type Accessible ¶
type Accessible interface {
GetAccessor(interface{}) *Accessor
}
Accessible is a type that has dynamically accessible fields.
type Accessor ¶
Accessor provides dynamic access to a structs fields.
func BuildAccessor ¶
BuildAccessor will build an accessor for the provided type.
type Coding ¶
type Coding string
Coding defines an encoding, decoding and transfer scheme.
type Map ¶
type Map map[string]interface{}
Map represents a simple map. It provides methods to marshal and unmarshal concrete types to and from the map using JSON or BSON coding.
func (*Map) Marshal ¶
Marshal will marshal the specified value to the map. If the map already contains data, only fields present in the value are overwritten.
func (*Map) MustMarshal ¶
MustMarshal will marshal and panic on error.
func (*Map) MustUnmarshal ¶
MustUnmarshal will unmarshal and panic on error.
type NoValidation ¶
type NoValidation struct{}
NoValidation can be embedded in a struct to provide a no-op validation method.
func (*NoValidation) Validate ¶
func (*NoValidation) Validate() error
Validate will perform no validation.