None of the above, sorry I didn't mean a tool called 'sql migrations' I meant I simply use sql files (rather than having a special language or config file that translates to sql which is another common approach).
I use something I wrote myself (see link in other comment). Nothing fancy and could be replicated easily - save sql files for migrations, run migration if not in db already, then store in the db the name of the migration run.
Migrations are a minor pain point for me. The libraries I've used don't support running (all) pending migrations; only those with a timestamp more recent than the previous one. This means we have to finesse the timestamps manually as migrations get merged into the main branch and deployed to various environments. As such, the value offered by the migration library is pretty minimal compared to just remembering to pipe a .sql file directly into the database. Hopefully there's a more robust option out there that I just haven't found yet.
I take the approach of storing the name of any migrations run in the database in a metadata table - this means you can run them out of order, restore from a backup then run migrations not yet run etc. to test or adjust them. With multiple devs it's often the case that we want to run things out of order on production too, so ordering by time doesn't work and running manually is error-prone.
Code for this here - it'd be pretty simple to put it in its own little tool or even a bash script or something, and there are surely some other tools that do something similar... This one psql only as it relies on the psql binary to load the sql, but hopefully gives you the idea. I haven't bothered developing it further to do things like run a single migration or down migrations as haven't required that so far.
Cool, because this is actually what I ended up with myself in a dummy Go setup of mine (after having reinvented AR's migrations poorly with a Bash script). I'm not really accustomed to Go's ecosystem yet, so:
>and code-generate the basic CRUD Go stuff from the schema
I guess you read schema.rb and output some structs and methods? Because a quick Google search only yielded some Yeoman plugins …
Yes, this. One of the things I love about go is the stdlib capabilities. I try to avoid a lot of frameworks as there seems to be too much "magic" going on that you end up having to figure out when it comes time to troubleshoot. The HttpRouter is bare bones enough to understand and build on top of while still adding some value and helping avoid creating boilerplate code on your own.
I put together a little example web app based based on a few popular packages, including gorilla / mux. It's not a framework, just a nice starting point for little apps.
We run grpc-web with a big single-page VueJS app on the frontend. That way, Go is just the Api server, and the frontend handles all the routing and stuff.
We will also try to go this path. What is your overall satisfaction with this approach? I saw that grpc-web is marked as alpha and the grpc team itself wants to implement something which is kind of comparable.
Same here. I was sceptical about code generation and the whole protobuf as a base thing but i'm really liking it. Especially when you throw opentracing in the mix.
Same here. I never really liked idea of frameworks like Spring/Django for Golang. Rather build very small services and mostly use just standard library, perhaps some simple packages for specific tasks.
We use this too. It's not bad if all you're ever doing is returning json, but escaping from their `rest.ResponseWriter` to a normal `http.ResponseWriter` is always sad when you need to write out anything else.
That's a pretty good summary of the rest of it for me too...pretty good, but sad that it doesn't adhere to the standard libs `http` interfaces
We've been pretty happy with https://gobuffalo.io so far. We're serving up a Vue.js app with it. We needed a single binary to deploy on a client's server with no external dependencies and buffalo fits the bill. It comes with a cli that runs webpack and does hot reloads on save. It also has a build command that will bundle all the assets up to shove in the binary.
I've been using the standard library, httptreemux and Chi, depending on how large the project is. I have also used Gorilla in the past, and sometimes use Alice to compose handlers. I prefer to stay close to the standard library, so as to not get stuck with code that depends too heavily on a third library with no easy way to entangle that dependency. I've still got nightmares from late '90s PHP and early 2000 Zope framework disasters... not with a 10 foot pole. Though when your application gets bigger, it makes sense to pull in a good library for some route grouping and helper functions – there are so many options, it's not worth your while to roll your own.
And unless you have very specific requirements, the performance is probably not a relevant concern in a real application either.
The Go standard library has most of what you need for basic API servers. However as has been stated here, some things are not worth spending time crafting yourself.
Also for modern Docker/Kubernetes ops environments you need some additional infrastructure for table stakes. Here's my standard Nulladmin.com stack:
64 comments
[ 5.1 ms ] story [ 120 ms ] thread(1) https://www.npmjs.com/package/sql-migrations
(2) https://flywaydb.org/documentation/migration/sql
(3) https://github.com/rubenv/sql-migrate
I use something I wrote myself (see link in other comment). Nothing fancy and could be replicated easily - save sql files for migrations, run migration if not in db already, then store in the db the name of the migration run.
We're using it in production on a few CoreOS projects.
Code for this here - it'd be pretty simple to put it in its own little tool or even a bash script or something, and there are surely some other tools that do something similar... This one psql only as it relies on the psql binary to load the sql, but hopefully gives you the idea. I haven't bothered developing it further to do things like run a single migration or down migrations as haven't required that so far.
https://github.com/fragmenta/fragmenta/blob/master/migrate.g...
Quite simple, does the job.
I've tried a bunch of other migration tools but I don't think anyone has done a better job of it than Rails has.
>and code-generate the basic CRUD Go stuff from the schema
I guess you read schema.rb and output some structs and methods? Because a quick Google search only yielded some Yeoman plugins …
There's a bunch of tools that do this already (one I know works is "xo"), but I wanted join-table support.
I love this about Go. A router and you are off and running.
It is so simple to wrap handlers with your own middleware for auth, pre-flighting etc.
I put together a little example web app based based on a few popular packages, including gorilla / mux. It's not a framework, just a nice starting point for little apps.
I really like how a proto file defines our whole Api. It makes designing and referencing the Api easy.
https://gobuffalo.io/
at my day job in fintech I use the standard library and gorilla/mux
That's a pretty good summary of the rest of it for me too...pretty good, but sad that it doesn't adhere to the standard libs `http` interfaces
Do augment it a bit here and there with other libraries.
And unless you have very specific requirements, the performance is probably not a relevant concern in a real application either.
Crazy fast and has worked fine under heavy load.
For building a REST API
[0] https://github.com/urfave/negroni
[1] https://github.com/husobee/vestigo
Also for modern Docker/Kubernetes ops environments you need some additional infrastructure for table stakes. Here's my standard Nulladmin.com stack:
Routing - https://github.com/go-chi/chi
Command flags - https://github.com/spf13/pflag
Config - https://github.com/spf13/viper
Logging - https://github.com/Sirupsen/logrus
Metrics - https://github.com/prometheus/client_golang/prometheus
SQL helper - https://github.com/jmoiron/sqlx
OpenTracing - https://github.com/opentracing/opentracing-go