nip/internal/pkg/encoding/encode.go

19 lines
249 B
Go
Raw Permalink Normal View History

2024-08-25 18:57:31 +08:00
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)
}