refactor: refactor to adapt new custom json marshaler

This commit is contained in:
yusing
2025-04-16 14:39:26 +08:00
parent cdfc9d553b
commit c2b606e63e
43 changed files with 232 additions and 189 deletions

View File

@@ -1,8 +1,9 @@
package atomic
import (
"encoding/json"
"sync/atomic"
"github.com/yusing/go-proxy/pkg/json"
)
type Value[T any] struct {
@@ -29,6 +30,6 @@ func (a *Value[T]) Swap(v T) T {
return zero
}
func (a *Value[T]) MarshalJSON() ([]byte, error) {
return json.Marshal(a.Load())
func (a *Value[T]) MarshalJSONTo(buf []byte) []byte {
return json.MarshalTo(a.Load(), buf)
}