8 ms·
With tools like ogen[1], one can take a single OpenAPI document and generate server code with a static router, request/response validation, Prometheus metrics,
by koito17 2y ago
With tools like ogen[1], one can take a single OpenAPI document and generate server code with a static router, request/response validation, Prometheus metrics, OpenTelemetry tracing, and more out of the box.
It can also generate clients and webhooks. Authentication is just declaring a SecurityScheme in the OpenAPI document then implementing a single function. The rest of the backend is just implementing a single interface. Unlike oapi-codegen, there is no need to tinker with routing libraries or middleware for authentication and logging.
Pair this with sqlc[2] and SQLite's `pragma user_version`, and you get type-safe database code and database migrations for free. I will concede that adding SQLite is a manual process, but its just two imports added to main.go.
Frontend is entirely your choice. Go's standard library provides good enough text templating that I don't miss ERB or Django-style templates. Using the standard library's `embed` package, one can easily embed static assets into a single binary, so deployment can be as simple as `go build` and moving the binary.
I have a hard time using languages besides Go for developing backends, because the code generation tools make Go as convenient as frameworks like Quarkus while staying lightweight and fast.
[1] https://ogen.dev/ https://ogen.dev/
[2] https://sqlc.dev/ https://sqlc.dev/
- multiplegeorges 2y ago> Frontend is entirely your choice. You are missing the entire point of Rails and making the OP's point for them. > Go's standard library provides good enough text templating Rails offers much more than this, this again makes OP's point for them.
- samtheprogram 2y agoSecond this. My GP missed the point — the integration with front end tooling all the way to the database means you get so much more for free.
- rednafi 2y agoExactly. I don’t want to waste time on trivial decisions like which frontend tool to use or what templating engine to pick. This is exactly why Go isn’t great for building full-stack apps. Every app in Go looks different because you have to assemble all the parts yourself. In contrast, RoR or Django provides a nice rubric to get you up and running quickly. That said, I still like Go when I need to spin up a microservice with a well-defined scope.
- adamtaylor_13 2y agoJust reading this kinda makes the OP’s point. This isn’t simple, when compared to Rails. The simplicity-yet-capability of Rails is hard to match.
- deleted 2y ago[deleted]