Documentation ¶
Overview ¶
Package fill assigns arbitrary values to struct fields using reflection. "fill" is case-insensitive, and obeys the "json" field tag if present. It's primary use is to support decoding data from a number of serialization formats (JSON,YAML,CBOR) into an intermediate map[string]interface{} value which can then be used to "fill" arbitrary struct values
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is returned when a field isn't found ErrNotFound = fmt.Errorf("not found") )
Functions ¶
func GetPathValue ¶
GetPathValue gets a value from the input struct, accessed using the path of dot-separated fields
func SetPathValue ¶
SetPathValue sets a value on a the output struct, accessed using the path of dot-separated fields
Types ¶
type ArbitrarySetter ¶
ArbitrarySetter should be implemented by structs that can store arbitrary fields in a private map.
type ErrorCollector ¶ added in v0.8.0
type ErrorCollector struct {
// contains filtered or unexported fields
}
ErrorCollector collects errors, merging them into one, while noting the path where they happen
func NewErrorCollector ¶ added in v0.8.0
func NewErrorCollector() *ErrorCollector
NewErrorCollector creates a new ErrorCollector
func (*ErrorCollector) Add ¶ added in v0.8.0
func (c *ErrorCollector) Add(err error) bool
Add adds a non-nil error to the ErrorCollector, noting the path where the error happened
func (*ErrorCollector) AsSingleError ¶ added in v0.8.0
func (c *ErrorCollector) AsSingleError() error
AsSingleError returns the collected errors as a single error, or nil if there are none
func (*ErrorCollector) PopField ¶ added in v0.8.0
func (c *ErrorCollector) PopField()
PopField removes the most recent field from the current path
func (*ErrorCollector) PushField ¶ added in v0.8.0
func (c *ErrorCollector) PushField(fieldName string)
PushField adds a field to the current path
type FieldError ¶ added in v0.8.0
FieldError represents an error when a value does not match the expected type
func (*FieldError) Error ¶ added in v0.8.0
func (c *FieldError) Error() string
Error displays the text version of the FieldError