Implementing a MongoDB CRUD API Using Go Generics
I had to write a simple CRUD REST API for a project I’m working on that contains quite a bit of database models in MongoDB. I started writing a controller and a service for each model, but I quickly realized that I was writing the same code over and over again. Surely there must be a better way to do this. Go Generics to the Rescue Go 1.18 introduced generics, which allows you to write functions and data structures that can work with any type....