func InsertFoo(v Foo) {
db.Exec(`INSERT INTO x (bla, bla2, bla3, bla4, bla5, bla6, ...) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ...)`, v.bla, v.bla2, v.bla3, v.bla4, v.bla5, v.bla6, ...)}
}
I have been thinking of auto generating these mappers using go generate, but hmm.. maybe next year.
Go type system makes generalization impossible if you also need type safety. Not only ORM are complicated but the fact that Go lacks generic programming features makes a Go ORM API even more horrible to use, so I'm not surprised at all there is no appealing ORM for Go.People suggest code generation, but it's not going to solve your problem. Each time the database or your code is updated one or the other has to update one or the other as well.
Modern ORMs at least more type-safe than SQL: there is no work with strings, only with autogenerated constants. Also ORMs abstract you not only from SQL coding, but also from specific for DBMS SQL: with ORM you can easily switch PostgreSQL to MySQL.
Modern ORMs at least more type-safe than SQL: there is no work with strings, only with autogenerated constants. Also ORMs abstract you not only from SQL coding, but also from specific for DBMS SQL: with ORM you can easily switch PostgreSQL to MySQL.
It's fairly common to use one database for production and another (often in memory) for testing, with an ORM hiding the differences.
> Why would someone want to switch from PostgreSQL to MySQL?
It's fairly common to use one database for production and another (often in memory) for testing, with an ORM hiding the differences.