Documentation ¶
Index ¶
- Constants
- func ExtractString(el r.Value) (ret string, err error)
- type Comment
- type Commenting
- type Comments
- type Encoder
- type GetReflectedValue
- type Iterator
- type MapTransform
- type StartCollection
- type TabWriter
- func (tab *TabWriter) Escape(s string) bool
- func (tab *TabWriter) Indent(inc bool)
- func (tab *TabWriter) Nextline()
- func (tab *TabWriter) Quote(s string)
- func (tab *TabWriter) Softline()
- func (tab *TabWriter) Space()
- func (tab *TabWriter) Tab()
- func (tab *TabWriter) WriteRune(q rune) (ret int, err error)
- func (tab *TabWriter) WriteString(s string) (int, error)
- type TellMapping
- type TellSequence
Constants ¶
const Dashing = "-"
the key for sequences
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Commenting ¶ added in v0.8.0
turns a value representing one or more comments into a comment iterator. the encoder uses the iterator to generate comments for collections.
var NoComments Commenting = nil
a nil commenting implementation for readability
type Comments ¶
type Comments interface { Next() bool // called before every element, false if there are no more elements GetComment() Comment // valid after next returns true }
comment access for collections
func CommentBlock ¶
expects that the value is a kind of string containing a standard tell comment block
func CommentSlice ¶ added in v0.8.0
an implementation of Commenting that walks the passed slice.
type Encoder ¶
type Encoder struct { Tabs TabWriter Mapper, Sequencer StartCollection MapComments Commenting SequenceComments Commenting }
func MakeCommentEncoder ¶
use the "CommentBlock" encoder
func (*Encoder) WriteMapping ¶
func (*Encoder) WriteSequence ¶
type GetReflectedValue ¶
if implemented by one of the iterators will be used instead of GetValue()
type Iterator ¶ added in v0.8.0
type Iterator interface { // return true if there are elements left Next() bool // return "-" for sequences GetKey() string // can panic if there are no remaining elements GetValue() any }
walk the elements of a collection
type MapTransform ¶
type MapTransform struct {
// contains filtered or unexported fields
}
customization for serializing native maps r.Value is guaranteed to a kind of reflect.Map
func (*MapTransform) KeyTransform ¶
func (m *MapTransform) KeyTransform(t func(keys r.Value) string) *MapTransform
change a reflected key into an encodable string the default uses reflect Value.String()
func (*MapTransform) Mapper ¶
func (m *MapTransform) Mapper() StartCollection
return a factory function for the encoder
func (*MapTransform) Sort ¶
func (m *MapTransform) Sort(t func(a, b string) bool) *MapTransform
sort keys; by default keys are written sorted as per standard go string rules.
type StartCollection ¶ added in v0.8.0
for sequences, value is guaranteed to be a reflect.Slice for mappings, value is guaranteed to be a reflect.Map
type TabWriter ¶
type TellMapping ¶
type TellMapping interface {
TellMapping() Iterator
}
controls serialization when implemented by a value that's being encoded
type TellSequence ¶
type TellSequence interface {
TellSequence() Iterator
}
controls serialization when implemented by a value that's being encoded