DEV Community

Stop using entgo...please

ShandonCodes on January 08, 2024

If you found this article, than you are probably similar to how I was a few months ago. I started a project in Go that required a SQL backend and I...
Collapse
 
blinkinglight profile image
M

what do you think about gorm.io/ ?

Collapse
 
mrwormhole profile image
Talha Altınel

burn it with fire, 8 levels deep nested reflection source code, a beginner's nightmare

Collapse
 
shandoncodes profile image
ShandonCodes

I have never dived into that project, but that source sounds like a nightmare. Is the use of reflection that only way to pull off a library like that?

Thread Thread
 
mrwormhole profile image
Talha Altınel • Edited

yea it requires parsing from struct tags for your custom structs but the problem with gorm is struct tag abuse and so many reflection caused by it

If you wanna skip SQL for an interview and wanna do very basic non-relational CRUD, it is the only use case of it.

Else, most of prod codebases uses standard library paired with sqlx or pgscan or sqlc lightweight approaches that only scans SQL results to given 1-by-1 fields with minimal "sql" struct tag parsing or with the help of Go type assertions on sql package types

Thread Thread
 
shandoncodes profile image
ShandonCodes

I see, good to know what can be found in more real-world scenarios for Go and SQL.

Thread Thread
 
helgi profile image
Oleg

Don't trust words alone. ~35k stars for Gorm repo should tell you something.
You can also check performance benchmarks: github.com/efectn/go-orm-benchmark...
It's not the best and not the worst.
Reflection is just another tool, that you shouldn't afraid.
Same thing is for Gorm, if you know where and how to use - go for it.
If not - it can be a good reason to learn/investigate.