mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-20 16:23:53 +01:00
feat: custom json marshaling implementation, replace json and yaml library (#89)
* chore: replace gopkg.in/yaml.v3 vs goccy/go-yaml; replace encoding/json with bytedance/sonic * fix: yaml unmarshal panic * feat: custom json marshaler implementation * chore: fix import and err marshal handling --------- Co-authored-by: yusing <yusing@6uo.me>
This commit is contained in:
17
pkg/json/encoder.go
Normal file
17
pkg/json/encoder.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package json
|
||||
|
||||
import "io"
|
||||
|
||||
type Encoder struct {
|
||||
w io.Writer
|
||||
}
|
||||
|
||||
func NewEncoder(w io.Writer) *Encoder {
|
||||
return &Encoder{w: w}
|
||||
}
|
||||
|
||||
func (e *Encoder) Encode(v any) error {
|
||||
data, _ := Marshal(v)
|
||||
_, err := e.w.Write(data)
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user