I love go, it’s a superb technology! I used it on a couple of projects and indeed it is rock solid. I feel that if the problem domain is well understood, then it’s a great fit.
However, I often don’t know what I’m building, I’m discovering along the way. And golang never felt great to me for exploration. So for that reason, I never felt good about using it for web dev either.
I’ve gotta say that my web apps have a small user base, but the business complexity is high, the domain is big.
Here is what bothered me at the time (code below was me fooling around, trying to get a feel of things, so warning code is very messy in some places).
Most golang programmers don’t feel the urge to consolidate knowledge into a common framework, thus rely upon golang’s stdlib. As a result, one can waste time trying to solve problems that have been solved many moons ago in other ecosystems.
Here’s an example, have a look at this code: golang-crud-example/main.go at 82cbcd5a047cffab071d3e7193c37ebb8d716ed0 · benjamin-thomas/golang-crud-example · GitHub
I was annoyed having to convert incoming HTTP strings params to ints. So I had the idea of creating an intKeyProvider function that would wrap around the the showCountry function.
Seemed to make sens, it would be a useful abstraction and would remove a lot of uneccesarry work. At the time I was used to ruby where the incoming params are already converted (after routing) for the programmer (which is just practical).
In the end, there was a lot of stuff similar to this, so it felt like re-inventing the wheel so I decided to just drop the idea of using golang for web dev.
Here’s the equivalent java/spring version: spring_address_book/CountryController.java at master · benjamin-thomas/spring_address_book · GitHub
It’s a solved problem, one has to learn the abstraction of the framework that’s all. From where I stand, I don’t anticipate all the problems I’m gonna face so I can appreciate if some of the work is already done for me.
As I said at the top of the post, SQL felt like a drag with golang (my apps are very database driven, like most business apps I would imagine).
Have a look here: golang-crud-example/countriesCRUD.go at 82cbcd5a047cffab071d3e7193c37ebb8d716ed0 · benjamin-thomas/golang-crud-example · GitHub
Here, the programmer has to remember to check for a possible error (triggered by the SQL library) after iterating on rows. I hate stuff like that, it’s so easy to forget. And in practice, I found there’s quite a lot of similar gotchas which I’m not fond of.
At the time, I remembered looking at rust, where not checking an error is made impossible, so that made me even less interested in the language (at least for my typical use case).
So to sum up, I’m context switching a lot, and can’t fit my main code base into my head. So that’s why I’m looking at other things. I want my tool to guide me along the way, scream at me if I forget something
So golang doesn’t look too good for me with that constraint.
Note: I’m aware of Buffalo, but not compelling enough for me comming from a rails background. In fact I really dislike all the string injection here: Querying · Buffalo
The golang/sql solution that appealed to me the most at the time was: GitHub - Masterminds/squirrel: Fluent SQL generation for golang
Java side, I think JOOQ is one of the most appealing options to me: change something db related, and everything breaks at compile time (which is what I want).
There was actually another library which I found that was even better but can’t remember its name, the concept is the same though.
So I know I’m going all over the place. All that to say I’m looking at a combination of great tooling at the language and library level but I also want constraints. The kind of good constraint I’m feeling from writing elm code, this is what pushed me to write this post. And I think I’d like to find that on the backend.
Thanks for your feedback though, I’m all ears if the golang ecosystem changed since I last looked at it