3 ms·
You can do a sorta-like getattr in Go using reflect, though I'm not sure exactly what your use case is. Fields need to be exported (upper-case names) though:
by georgemcbay 14y ago
You can do a sorta-like getattr in Go using reflect, though I'm not sure exactly what your use case is. Fields need to be exported (upper-case names) though:
http://play.golang.org/p/XPgHkKCz_D http://play.golang.org/p/XPgHkKCz_D
But you're absolutely right, you trade in some easy expressiveness and lack of boilerplate for better performance and easy concurrency.
But Go is much better about the boilerplate required than most other static/compiled languages, IMO.
- waterside81 14y agoI like your solution but that's kind of the rub about Go, at least at this stage of its still-early life. You have to re-invent the wheel a lot. It's frustrating to have to implement things that you know exist elsewhere, especially things like collections.defaultdict in Python. Agree re: boilerplate. Much slimmer than Java or C++. And the build times, my God, the build times. It almost makes up for not having a true REPL.