mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
check error when json.Unmarshal failed
This commit is contained in:
parent
f8134deb63
commit
ca7e263a29
@ -31,7 +31,10 @@ type Duration struct {
|
||||
// UnmarshalJSON implements the json.Unmarshaller interface.
|
||||
func (d *Duration) UnmarshalJSON(b []byte) error {
|
||||
var str string
|
||||
json.Unmarshal(b, &str)
|
||||
err := json.Unmarshal(b, &str)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pd, err := time.ParseDuration(str)
|
||||
if err != nil {
|
||||
|
@ -104,7 +104,10 @@ func (t *MicroTime) UnmarshalJSON(b []byte) error {
|
||||
}
|
||||
|
||||
var str string
|
||||
json.Unmarshal(b, &str)
|
||||
err := json.Unmarshal(b, &str)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pt, err := time.Parse(RFC3339Micro, str)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user