go-yaml
go-yaml copied to clipboard
EncodeToNodeContext doesn't encode comments
Hi,
This is a great library!
While I'm playing with it, I found that EncodeToNodeContext
doesn't respect CommentMap option.
However from following code, it seems the comments also encoded into node before written out.
// EncodeContext writes the YAML encoding of v to the stream with context.Context.
func (e *Encoder) EncodeContext(ctx context.Context, v interface{}) error {
node, err := e.EncodeToNodeContext(ctx, v)
if err != nil {
return errors.Wrapf(err, "failed to encode to node")
}
if err := e.setCommentByCommentMap(node); err != nil {
return errors.Wrapf(err, "failed to set comment by comment map")
}
var p printer.Printer
e.writer.Write(p.PrintNode(node))
return nil
}
Is there any special consideration that not putting the comments code into EncodeToNodeContext
?
Thanks. Jia