Re:Go: Ten years and climbing
by rhinoceraptor on Thursday September 21, 2017 @10:24PM
(#15308984)
I don't use go, but it doesn't really seem like CRUD apps are the sweet spot for it. When I think of go, I think of system software, that 10 years ago would have been written in C. I don't think of it as replacing Rails.
Re:Go: Ten years and climbing
by christophilus on Thursday September 21, 2017 @10:20PM
(#15308969)
Yeah. The repeating the field, only camelCased, in JSON annotations feels needlessly painful to me. Subjective, I know, but that kind of painfulness seems pervasive in my (brief) dabbling with Go, and is one of the main reasons I moved on.
The json annotation is optional, but very powerful since it allows you to set the mapped name of the field to any name you like, allowing you to map json fields with snake_case, CamelCase, kebab-case, etc.
One alternative to writing struct tags by hand is to write a little generator code to map the field names from, say, a reference .json, then calling `go generate` as part of your build process.
I've wondered whether a wrapper library could do rule-based field name mapping automatically with Go's reflection facilities (which could be a productivity win), but I haven't really looked at it closely.
Admittedly, mapping objects to/from database entries is a bit more complicated. There are several ORMs out there or you can role your own.