I am working on a function that uses reflection. The code in question can be found here: go playground
For some reason, when I try to run the exact same code from main()
but in a unit test, I get very strange and contradictory results. That code panics on line 23 with the following: panic: reflect: call of reflect.Value.Elem on struct Value
.
If I change the code and remove the trailing .Elem()
call on line 23, it then panics again with the following: panic: reflect: NumField of non-struct type
.
So according to the unit test, that value is somehow simultaneously a pointer and not a pointer.
Any idea why the behaviour of the exact same code changes depending on where it's run? Could it be a bug with GoLand, or something else?
Aucun commentaire:
Enregistrer un commentaire