reflectwalk
reflectwalk copied to clipboard
cannot control walk via reflectwalk.SkipEntry
I find it hard to control whether the walk visits objects or not.
In particular when SliceElem() returns reflectwalk.SkipEntry what I would expect is "don't descend into this element, but continue to the next one". But, what happens is "don't continue to the next one" (Contrast this behavior with StructField, where SkipEntry does continue to the next field. The comment in code says "pretends this field doesn't even exist".) I can't see any way to skip descending into a slice element, but do continue to visit the remaining elements.
Another troublesome aspect is that errors returned by Enter() and Exit() are simply ignored. I had to look into reflectwalk.go to figure out why returning SkipEntry there had no effect.
If I'm using the API incorrectly, please let me know. Thanks!
SkipEntry was added quite a bit later so its very likely that it just wasn't thoughtfully added to all code paths. I also agree that your description of slice behavior also sounds unintuitive... I don't have time today but I'll take a look at this.