Skip to content
Bogdan Dinu edited this page Feb 13, 2020 · 1 revision

The necessity for Stroo has risen from the fact that we needed to solve a "small" problem at work: while our client delivered json having properties named using camelCase, our 3rd party returned json with properties named using lower_case with underscore naming convention.

Because the standard encoding/json package doesn't support that, we had to implement the MarshalJSON and UnmarshalJSON ourselves. Doing so would imply that on every change of that struct, we should reflect those changes into the implementation of Marshal/Unmarshal - which is a really boring task, not to mention that paying attention could drain your energy.

For that reason, I have decided to create Stroo, a tool that inspects a package that is indicated by the developer, constructs meaningful information from that and provides it to a template that developer has created in order to generate Go code.

The main advantage of this way of generating code is that code doesn't need to import anything from stroo and you can carry around the template with your repository. Just run the go generate as usual, every time your package changes and the code will be generated for you.

Clone this wiki locally