NewEncoder returns a new YAML encoder that writes to w.
(w io.Writer, options ...EncoderOption)
| 74 | |
| 75 | // NewEncoder returns a new YAML encoder that writes to w. |
| 76 | func NewEncoder(w io.Writer, options ...EncoderOption) *Encoder { |
| 77 | enc := &Encoder{w: w, indentSize: 2} |
| 78 | for _, opt := range options { |
| 79 | opt(enc) |
| 80 | } |
| 81 | if enc.Colors == nil { |
| 82 | enc.Colors = &Colors{ |
| 83 | KeyColor: color.New(), |
| 84 | ValueColor: color.New(), |
| 85 | CommentColor: color.New(), |
| 86 | } |
| 87 | } |
| 88 | return enc |
| 89 | } |
| 90 | |
| 91 | // lineBreakV decides whether or not a line break should be written based in |
| 92 | // the type of v. It returns an indentation increment, a boolean indicating if |
no outgoing calls