1 Commits

Author SHA1 Message Date
4f66db0d1b Merge 2e6110e54a into e3cbe1e9b4 2024-11-26 21:30:28 +00:00
2 changed files with 4 additions and 9 deletions

View File

@ -1,7 +1,7 @@
{ {
"method": "GET", "method": "GET",
"url": "https://example.com", "url": "https://example.com",
"no_proxy_check": true, "no_proxy_check": false,
"timeout": 10000, "timeout": 10000,
"dodos_count": 50, "dodos_count": 50,
"request_count": 1000, "request_count": 1000,

View File

@ -65,17 +65,12 @@ func (o *option[T]) SetNone() {
} }
func (o *option[T]) UnmarshalJSON(data []byte) error { func (o *option[T]) UnmarshalJSON(data []byte) error {
if string(data) == "null" || len(data) == 0 { if string(data) == "null" {
o.SetNone() o.none = true
return nil return nil
} }
if err := json.Unmarshal(data, &o.value); err != nil {
o.SetNone()
return err
}
o.none = false o.none = false
return nil return json.Unmarshal(data, &o.value)
} }
func NewOption[T NonNilT](value T) *option[T] { func NewOption[T NonNilT](value T) *option[T] {