NewDecoder returns a new decoder based on the given input format. If the input format does not imply otherwise, a text format decoder is returned.
(r io.Reader, format Format)
| 73 | // NewDecoder returns a new decoder based on the given input format. |
| 74 | // If the input format does not imply otherwise, a text format decoder is returned. |
| 75 | func NewDecoder(r io.Reader, format Format) Decoder { |
| 76 | switch format { |
| 77 | case FmtProtoDelim: |
| 78 | return &protoDecoder{r: r} |
| 79 | } |
| 80 | return &textDecoder{r: r} |
| 81 | } |
| 82 | |
| 83 | // protoDecoder implements the Decoder interface for protocol buffers. |
| 84 | type protoDecoder struct { |
no outgoing calls