4 ms·
On small projects, I just write out the boilerplate. It's annoying but it's straightforward to read and revisit years later. On larger projects (100k LOC+) I u
by hellcow 5y ago
On small projects, I just write out the boilerplate. It's annoying but it's straightforward to read and revisit years later.
On larger projects (100k LOC+) I use chi for my router in combination with codegen via sqlc and moq, and I wrote a small program to generate the routes for me automatically with a config file.
- jjice 5y agosqlc is very interesting. Gives me sqlx (from Rust, not the Go package) vibes. Definitely will play around with this.
- zinclozenge 5y agoThere's a variety of projects out there. gorilla/mux, chi, httprouter are all pretty commonly used for just defining routes. If you want a full on framework, gin and beego are also common. For the database (I'm unfortunately mainly familiar with postgresql related projects) there's pgx, sqlx, gorm, and then code generators like sqlc such as sqlboiler and entgo. Golang encourages libraries and frameworks with much smaller surface, so there is indeed a boilerplate issue, but that's also an issue with golang as a whole.