Richard Bucker

Web apps and frameworks in Go

Posted at — Feb 5, 2015

I’m trying something new. I’m going to write this review while I’m getting acquainted with that which I’m reviewing. Granted this is not an in depth deep dive but it is the first blush. And while they say don’t judge a book by it’s cover, in this case it’s README file,  there are simply too many 3rd party web frameworks out there for go.The granddaddy of them all is revel. What makes Revel great is that it feels feature complete. The menu in it’s manual makes it pretty clear what it supports. The only thing I do not see is some sort of integrated ORM. It’s not compulsory but it could be helpful. I’ve implemented a few projects and while they work they are not very gratifying.When creating a REST API server it seems obvious that the handlers and documentation should be generated. There are a number of tools for that. For the moment the defacto leader seems to be swagger. From the swagger toolchain (nodejs) there are other tools that capitalize in order to generate multi-lingual client SDKs. Regardless of the streamlined nature of the toolchain I’d prefer to be homogenous for the moment (I’ve previously written about Chef, Puppet, Ansible and SaltStack in this area). go-restful will use the swagger API docs to create a go webserver but without examples or documentation it’s not valuable. A second go-restful project trumped the first with some docs and a few supporting blog posts. Swagger’s own codegen is a whole crapload of templates and so it does not benefit from any sort of reflection.One cool project that feels like it hits the balance between a 3rd party library that makes my life easier without having to be concerned about the cruft is httprouter. It’s a small project with a reasonable README file that covers the different aspects of the library. I like that it partitions the routes by method but I’m not sure I like the parameter handling. On the one hand it’s nice to have the feature because the stdlib does not support it at all and the maintainer reports that there are no leaks or heap usage… but there has to be a latency in the regex for parsing parameters from the path string. That said it still matches with my sensibilities."Goji is a minimalistic web framework that values composability and simplicity." It seems to me that given their examples and documentation that if you’re going this way then just use httprouter and do the rest yourself. Goji does not add any noticeable sugar."Gin is a web framework written in Golang. It features a Martini-like API…" Anything that is **-like starts to lose my attention. If I needed a like I would probably build a like myself. At least this way when things started to deviate from the norm it would be on me and not on the 3rd parties digression. Gin is marching toward 1.0. There is some activity but not much. The logging is colorized which is useless but it has integrated httprouter suggesting that it’s 40 times faster. Faster than what (they do not say)?Ace, dead and no docs or examples.Here is a benchmark for a number of frameworks. If you try to read the link from your phone… no real joy. The results favored httprouter which up until this moment I thought was a library and not a framework.In that spirit I’ll include vulcand which is a load balancer. The compelling story here is that it uses etcd in order to configure and update the routes. While mailgun reports that it’s still beta code they are running it in production with a modest workload. I do not know what modest is or in what use-case but I know those guys and I believe they are being modest. The mailgun team have a number of other projects… They have their own router which does not work like httprouter and would appear to be too far into the transaction to be anywhere close to the httprouter benchmark. mailgun has a logger however the config seems to be a toml or yaml file.  That’s just silly these days. And then they have a webserver that looks like a httprouter and a json config file had a baby. What makes scroll a nice selection is that with just a little reflection it would be possible to create composable routing tables at runtime and from there you might be able to get to something that looked like a flow based programming framework.swiperproxy has a great name but it’s python. I like python but I’ll be happy if I can forget the experience. HAProxy, nginx and vulcand are capable replacements.So I’ve made it to the bottom of this list. I don’t think I hate everything as there are a few gems (not to be confused with ruby-lang) in the ruff. httprouter being one of them.