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.
Yes. I think the most popular is gorm (https://gorm.io). I use it myself and love it, but i know that many people are against using it. For simple queries, the code is looking really clean. If you have complex queries with e.g. sub selects, your code looks like a car accident.
I've used https://entgo.io/ for a few years now. It's pretty good. A few quirks trying to get some things to do what I want, but overall easy to work with.
I'd rather suggest the use of tools more aligned with the core concepts of the language such as sqlx, which is an extension of the database/sql standard library. It allows you to use models/structs to map your tables but you have more control over the SQL statements you use to perform queries and the like. You can combine sqlx with Squirrel to build queries from composable parts.
I'd rather suggest the use of tools more aligned with the core concepts of the language such as sqlx, which is an extension of the database/sql standard library. It allows you to use models/structs to map your tables but you have more control over the SQL statements you use to perform queries and the like. You can combine sqlx with Squirrel to build queries from composable parts.
Try go-jet, it generates the models based on the schema, provides typed column names.
At the end of the day, it's up to you to decide how you want to work with your Database. Whether you like to write your own SQL query or let the ORM do it for you probably won't matter until you hit a certain scale anyway. If you're curious about others options, as many mentioned, SQLC (https://sqlc.dev/) is really a good one which is getting some traction these days. You basically write some SQL with placeholders in files and it compiles it for you into type-safe struct and code to interact with. Here is also a nice (and short) blog post explaining the options we have in the go ecosystem and the choice of the author to move to SQLC. https://brandur.org/sqlc
This one looks interesting if you like GraphQL… https://graphjin.com