Encode encodes an Encodable to an io.Writer.
(w io.Writer, e Encodable)
| 154 | |
| 155 | // Encode encodes an Encodable to an io.Writer. |
| 156 | func Encode(w io.Writer, e Encodable) error { |
| 157 | wr := NewWriter(w) |
| 158 | err := e.EncodeMsg(wr) |
| 159 | if err == nil { |
| 160 | err = wr.Flush() |
| 161 | } |
| 162 | freeW(wr) |
| 163 | return err |
| 164 | } |
| 165 | |
| 166 | func (mw *Writer) flush() error { |
| 167 | if mw.wloc == 0 { |
searching dependent graphs…