|
|
@ -1,15 +1,16 @@ |
|
|
|
package config |
|
|
|
package config |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"encoding/json" |
|
|
|
stdjson "encoding/json" |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
"reflect" |
|
|
|
"reflect" |
|
|
|
"strconv" |
|
|
|
"strconv" |
|
|
|
"sync/atomic" |
|
|
|
"sync/atomic" |
|
|
|
"time" |
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
|
|
"google.golang.org/protobuf/encoding/protojson" |
|
|
|
|
|
|
|
"google.golang.org/protobuf/proto" |
|
|
|
"google.golang.org/protobuf/proto" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/go-kratos/kratos/v2/encoding/json" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
var ( |
|
|
|
var ( |
|
|
@ -128,14 +129,14 @@ func (v *atomicValue) Duration() (time.Duration, error) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (v *atomicValue) Scan(obj interface{}) error { |
|
|
|
func (v *atomicValue) Scan(obj interface{}) error { |
|
|
|
data, err := json.Marshal(v.Load()) |
|
|
|
data, err := stdjson.Marshal(v.Load()) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
if pb, ok := obj.(proto.Message); ok { |
|
|
|
if pb, ok := obj.(proto.Message); ok { |
|
|
|
return protojson.Unmarshal(data, pb) |
|
|
|
return json.UnmarshalOptions.Unmarshal(data, pb) |
|
|
|
} |
|
|
|
} |
|
|
|
return json.Unmarshal(data, obj) |
|
|
|
return stdjson.Unmarshal(data, obj) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type errValue struct { |
|
|
|
type errValue struct { |
|
|
|