Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
use some lib that facilitates SQL generation, like Squirrel
db.go - contains the interfaces, structs, and constructors
For that, I used the lib go-sqlmock. So, for example, the following snippet is part of the person/service_test.go file:
I will present in this post a project that fits in the last category: sqlc.
Implement the Repository interface by writing the queries in code, perhaps using some solution like Squirrel or sqlx.