I have this payload,
type test_struct struct {
Id string `json:"id"`
Desc struct {
Id int `json:"id"`
Name int `json:"name"`
} `json:"desc"`
}
The problem is that sometimes the value of Desc struct is just NULL, and I will get this error,
http: panic serving 10.130.2.1:60426: runtime error: index out of range [2] with length 1
goroutine 6 [running]:
net/http.(*conn).serve.func1()
.
.
.
There’s no error if Desc have array values but I cannot of course make it without NULL value all the time.
If I do this,
type test_struct struct {
Id string `json:"id"`
Desc []interface{} `json:"desc"`
}
I will have this error,
json: cannot unmarshal object into Go struct field test_struct.desc of type []interface {}
http: panic serving 10.4.200.1:45812: runtime error: index out of range [2] with length 1
goroutine 18 [running]:
Thanks!