Ask HN: What do you think is the current best Go webframework and why?
Without making grand pronouncements about The Right Way, I at least get why the Go community shies away from all-inclusive frameworks after years of using Django. An all-inclusive framework is super helpful for getting started quickly, but the way its components can be deeply tied with each other can make life tricky when you want to do some things that weren't quite what the framework authors envisioned. If you glued the components together yourself, you at least know they're separable and where they fit together.
There are popular packages for the sorts of things that a lower-level Python framework might:
- http://www.gorillatoolkit.org/ has a more flexible router, sessions, and some other basics on the Web side
- Built-in html/template is a pretty good place to start. (The context-aware escaping is something I wish I had.)
- Popular database tools include jmoiron/sqlx and jinzhu/gorm on GitHub.
- gokit.io is mostly about internal services rather than frontends, but may have parts of general interest. It includes example services.
- godoc.org links to a bunch of popular packages and has search and such. Incidentally, its own source is available: https://github.com/golang/gddo
I'd say Go is not going to get you to a releasable DB-backed Web app anywhere near as fast as Django or any of the other well-known dyn-language frameworks. I think the language has the bones where you could get that sort of app to faster time-to-first-usefulness, without entirely giving up the easy-to-follow-what's-happening and pick-your-parts aspects, but probably not there now.
While I agree with you and I tend to stay as lean as possible, it always perplexes me why people want a Django/RoR/Phoenix in Go.
These other frameworks are mature and battle tested enough in agreeable enough programming languages, why attempt to reinvent them in Go?
Go's strength and afaik original purpose for Google was for creating smaller services, not a web app monolith.
The wanting part I get: a lot of people do database-backed Web apps, some of them (us!) see some useful attributes in Go and would like to have access to them in our world too.
Personally I get that appeal more strongly now that in Django-land we're well over 100K LOC and dealing with a lot more traffic and so on than when we started. Helping folks scale gracefully from "tiny app you can get going very soon" to "larger app that's still cool to maintain" might be where there's the most unfilled need.
The truly hard part is figuring out what improvements you can achieve without host/graft disease, where either the language itself or softer factors keep the mashup from working satisfactorily.
That is, one way to fail at improving DB-backed webapps in Go is the obvious one: you don't actually make them easy to build. Another is if you do make it easy to get started, but in the process lose the things that made it appealing to use Go. Those might be "hard" technical attributes like static checks and decent perf, or "soft" human- and standards-oriented things about Go: flexibility in choosing libs you want, or norms favoring explicit code where it's possible to work out what's really running from what's on the page.
Feeling out those tradeoffs is probably a long, communal process with a lot of trial-and-error. Certainly it's slower and harder than just trying to translate the dyn-language tools already out there. But I think it is possible and could be really useful.
Great answer! Starting to learn the components with Ruby on Rails or Django and then moving to Go, gluing parts together seems to be a good way to get from zero to great apps.
I prefer just using the standard library with a muxer like gorilla/mux.
I second this approach. The go standard library has a multitude of utilities that make spinning up a Web application fairly straightforward. Moreover, utilizing the standard library gives you greater leverage when you need to adapt to the unique needs of your application.
Because the more fully kithensunk ones are worse/bad/negative or just because you keep it simple?
I prefer less opinionated where possible. "Worse" is really subjective, I just don't need bells a whistles for many of my projects, so the stdlib is just fine.
OP's question is far too broad to elicit useful answers.
Start with a feature list of what you require from the framework.
- Validation
- Routing
- Security
- Filtering
- Templating
- Data binding
- Component reuse
...I think the idea of a web framework in Go is too application level oriented where as Go is a great language to write infrastructure. If you implement a microservice, look for microservice frameworks. A web application itself seems to broad. I would almost always recommend to find a custom implementation.
Really really close to flagging this. There is no "best X" for any X. At least not without adding lots of context (and then it gets boring for other people since these details probably are not interesting for them).
First of all, the question specifically asks for the opinion of the commenter and their reasoning. Seems quite reasonable to me.
Second, the statement "there is no 'best X' for any X" seems to me to be plainly false. Is there any doubt about the best gamecube emulator for linux? How about the best route to take on a bicycle from among two, one which offers safe, removed bike paths, and one which forces the rider into heavy traffic?
Once in a while, there is a best X, and questions like this might help to identify for (or indicate the absence of one).
Nope. Maybe for a short time, but even then you can find plenty of context examples for which it doesn't apply. E.g. for you the beautiful-scenere route is usually the best bike route, but right now you are tired and have some other important things to do at home, so right now the shortest path is the best.
For the purposes of the hypothetical, let's assume the safe bike path is also shorter.
If I am starting to learn Go and want to try my hands at building a web service, what should I use?
For learning purposes, I might suggest the Go implementation of gRPC[1]. As the name implies, it is RPC focused and so doesn't necessarily translate well to a complete web service (HATEOS and such), but still provides some insights into how you might structure your code for that kind of project.
This is a really good question to ask.