4 ms·
Yes. I've used Rails extensively before writing some larger sites in Go. Quick comparison of Go vs Rails: Pros: More performance, multi-threaded extremely cap
by grey-area 5y ago
Yes.
I've used Rails extensively before writing some larger sites in Go. Quick comparison of Go vs Rails:
Pros: More performance, multi-threaded extremely capable web server built-in, culture of simplicity and low-dependencies, no breaking changes, goroutines, ideal for small services, static binaries (all deps included) so no need for rbenv, docker etc etc, no included JS, great stdlib (far better than Ruby's IMO), NO INHERITANCE.
Cons: No standard structure others are familiar with, you'll need to find/write code for things like migrations, auth, rendering views, skeleton code generation.
For things you need to find/write this may seem intimidating but it's an opportunity to explore the bits you liked about rails and jettison the bits you didn't like or need, and the stdlib includes a lot of what you need at a low level (e.g. html templating, crypto libs). I cannot emphasise the importance of no breaking changes, it's so refreshing compared to other language ecosystems like Ruby or JS.
Overall I'm really happy with Go for web apps and would choose it again in a heartbeat, particularly over Ruby and Rails (which I also like, but has performance issues and cultural issues IMO).
- copperx 5y agoIs there a canonical ORM to use in Go, or would raw SQL be preferred?
- korginator 5y agoThere are ORMs available for Golang, but my experience has been better with packages like sqlx [1] or dat [2]. We've since been using SQLX for pretty much all DBMS related work, and regret nothing. In my experience SQLX gave us the right balance between abstraction and control. [1] http://jmoiron.github.io/sqlx/ http://jmoiron.github.io/sqlx/ [2] https://github.com/mgutz/dat https://github.com/mgutz/dat
- grey-area 5y agoNot really no, the lack of generics has hampered this as you can't easily return slices of arbitrary objects from an ORM so existing ORMs are pretty ugly. One way round this at present is code generation. From your comment I think you're talking about a query builder/executor though, which is a specific part of an ORM, they're pretty simple to build if that is your thing or there are a few examples of that out there. You're really just building up an sql string, storing params, adding a few helpers for things like joins and then executing. I personally use a query generator to generate consistent queries, and generated code per resource to create models from results.