Generating the boilerplate

The clean separation of concerns and neat architectural layering of Go kit has a price. The price is a lot of boring, mind-numbing, and error-prone boilerplate code for translating requests and responses between different structs and method signatures. It is useful to see and understand how Go kit can support strongly-typed interfaces in a generic way, but for large-scale projects, the preferred solution is to generate all the boilerplate from the Go interfaces and data types. There are several projects for this task, including one under development by Go kit itself called kitgen (https://github.com/go-kit/kit/tree/master/cmd/kitgen).

It is considered experimental at the moment. I'm a big fan of code generation and highly recommend it. However, in the following sections, we will look at a lot of manual boilerplate code to make it clear what's going on and avoid any magic.