3 ms·
Even though I know they're well-designed, I find Go's web templates hard to work in. So I avoid them. My stack is basically: - Postgres, using pq and sqlx -
by tptacek 9y ago
Even though I know they're well-designed, I find Go's web templates hard to work in. So I avoid them.
My stack is basically:
- Postgres, using pq and sqlx
- A codegen ORM I wrote that scrapes schemas and generates CRUD and lookup functions for all my database types. I don't think dynamic ORMs like gorm are the way to go for Go.
- A session library I wrote a year ago, and simple Go wrapper handlers to require sessions, enforce authentication, &c, passing things like "current user" and "current session" down to standard net/http Handlers through Context.
- 10-or-so JSON utility functions I take with me from project to project.
- React, via create-react-app, so I all my templating is done in JSX.
- net/http/httptest for testing.
- aalhour 9y agoAny chance you have that ORM of yours open-sourced somewhere?
- tptacek 9y agoNo, but (1) sqlboiler is a much better ORM, and (2) it is surprisingly easy to build these things yourself; mine's just a bunch of text/template templates and ~100 lines of Go code to scrape a Postgres schema. (I mean: this code will be open sourced pretty soon, since it's part of a bigger open source thingy I'm releasing, but the ORM isn't very good, just as good as I needed it to be; nobody should ever use it for another project.)
- aalhour 9y agoGo it. Sounds like a fun educational project to build, an ORM tgat scrapes a PostgreSQL database and provides primitives to query it.