mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +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.
|
// UnmarshalJSON implements the json.Unmarshaller interface.
|
||||||
func (d *Duration) UnmarshalJSON(b []byte) error {
|
func (d *Duration) UnmarshalJSON(b []byte) error {
|
||||||
var str string
|
var str string
|
||||||
json.Unmarshal(b, &str)
|
err := json.Unmarshal(b, &str)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
pd, err := time.ParseDuration(str)
|
pd, err := time.ParseDuration(str)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -104,7 +104,10 @@ func (t *MicroTime) UnmarshalJSON(b []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var str string
|
var str string
|
||||||
json.Unmarshal(b, &str)
|
err := json.Unmarshal(b, &str)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
pt, err := time.Parse(RFC3339Micro, str)
|
pt, err := time.Parse(RFC3339Micro, str)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user