Leveraging generated code for building a REST API and SQL queries: joys and pains

By Jaideep Khandelwal

Elevator Pitch

In this talk, I will share my experience to build a backend system with REST APIs using Go’s generated code. From writing API specs to native SQL queries, we will talk about the joy of getting a boiler plate code to get started, but how over a period of time it becomes pain if not done right.

Description

Takeaways

  • Usefulness of generated code to build services in golang. Example - Faster integration tests to improve quality or native SQL queries to type safe code.
  • Not so usefulness of generated code and where to avoid. Challenges like maintenance of code with growing team, merge conflicts etc.
  • We talk about some of the libraries one can use to generate boiler plate code, which gives a head-start.
  • From day 0 to day 100, the evolution of the codebase looks like.

Notes

The nature of my work requires me to be a polyglot. While, building a SaaS platform for a security company, we ended up using go libraries to generate code. Initially, I was hesitant, but had mixed opinions as days progressed. In my opinion this can be a helpful session for beginner to intermediate level engineers to understand pros and cons.