Documentation ¶
Overview ¶
Package fill provides fillers that fills each field with a value.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrCodecMismatch = errors.New("unsupported codec")
)
Functions ¶
This section is empty.
Types ¶
type Filler ¶
type Filler interface { // Fill receives a struct v and corresponds input that is have internally to the struct. // Fill may return these errors: // // - io.EOF: At the end of input. // - ErrCodecMismatch: If v isn't a supported type. // Fill(v interface{}) error }
Filler tries to correspond input text to a struct.
type InteractiveFiller ¶ added in v0.9.0
type InteractiveFiller interface { // Fill receives a struct v and corresponds input that is have internally to the struct. // Fill may return these errors: // // - io.EOF: At the end of input. // - ErrCodecMismatch: If v isn't a supported type. // Fill(v interface{}, opts InteractiveFillerOpts) error }
Filler tries to correspond input text to a struct interactively.
type InteractiveFillerOpts ¶ added in v0.9.1
type InteractiveFillerOpts struct { // DigManually is true, Fill asks whether to dig down if it encountered to a message field. DigManually, BytesFromFile, AddRepeatedManually bool }
InteractiveFillerOpts represents options for InteractiveFiller.
type SilentFiller ¶
type SilentFiller struct {
// contains filtered or unexported fields
}
SilentFilter is a Filler implementation that doesn't behave interactive actions.
func NewSilentFiller ¶
func NewSilentFiller(in io.Reader) *SilentFiller
NewSilentFiller receives input as io.Reader and returns an instance of SilentFiller.
func (*SilentFiller) Fill ¶
func (f *SilentFiller) Fill(v interface{}) error
Fill fills values of each field from a JSON string. If the JSON string is invalid JSON format or v is a nil pointer, Fill returns ErrCodecMismatch.
Click to show internal directories.
Click to hide internal directories.