samedi 1 juillet 2017

Call of reflect.Value.Set on zero Value error

I am unable to assign a value to a pointer using Elem().Set(). I am getting an call of reflect.Value.Set on zero Value error. I checked the value that I am passing and saw that it isn't nil. I have worked on the same function before and it was working fine then. Is there anything that I am missing here?

outputInterfaceAlias := reflect.ValueOf(output)
fmt.Printf("kind: %+v\n", outputInterfaceAlias.Kind())
if outputInterfaceAlias.Kind() != reflect.Ptr {
    panic("Passed value in output interface must be of POINTER type")
}
val := reflect.ValueOf(asyncOutput)
fmt.Printf("value: %+v\n", val)
outputInterfaceAlias.Elem().Set(val)

The output I got was:

kind: ptr
value: map[value:[map[SUM:2.711528e+06 SUM(total):4909]]]
echo: http: panic serving [::1]:60153: reflect: call of reflect.Value.Set on zero Value





Aucun commentaire:

Enregistrer un commentaire