3 ms·
Do you also avoid using packages like encoding/js, which make equally liberal use of struct tags and reflection?
by CamouflagedKiwi 2y ago
Do you also avoid using packages like encoding/js, which make equally liberal use of struct tags and reflection?
- cedws 2y agoencoding/json does not make liberal use of struct tags, it uses only one. It's also battle tested and lives in the standard library. I don't have faith in many other projects to get bug-prone reflection code right.
- CamouflagedKiwi 2y agoIt does have a microformat within that single tag though ("x,omitempty" etc) so there is a bit more complexity than 'just one tag' indicates. Anyway, I think you're overstating how hard reflection-based code is. Yes, it is tricky and should mostly be avoided, but it's not beyond the scope of human intellect to understand (especially Go's which is pretty sensible).