package encoding import ( "encoding/json" "io" ) type encoder struct { w io.Writer } func NewEncoder(w io.Writer) Encoder { return &encoder{w} } func (e *encoder) Encode(v interface{}) (err error) { return json.NewEncoder(e.w).Encode(&v) }