Anyone using https://github.com/knq/xo?

247 views
Skip to first unread message

Nate Finch

unread,
Jul 20, 2017, 12:04:35 AM7/20/17
to golang-nuts
We're thinking of dropping gorm and switching to plain old database/sql... but I don't really want to generate all that boilerplate myself.  xo looks like it does a reasonable job of generating the boilerplate for you, so I was wondering if anyone had any experience using it in production.  Gotchas, etc.

-Nate

Michael Banzon

unread,
Jul 20, 2017, 2:56:21 AM7/20/17
to Nate Finch, golang-nuts
Just out of curiosity - why switch away from gorm??

We've just switched from gorp to gorm - with great success. The main reason I could find for going (pun intended) is to have one less dependency.

--
Michael Banzon

Den 20. jul. 2017 kl. 06.04 skrev Nate Finch <nate....@gmail.com>:

We're thinking of dropping gorm and switching to plain old database/sql... but I don't really want to generate all that boilerplate myself.  xo looks like it does a reasonable job of generating the boilerplate for you, so I was wondering if anyone had any experience using it in production.  Gotchas, etc.

-Nate

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Steven Hartland

unread,
Jul 20, 2017, 4:09:51 AM7/20/17
to golan...@googlegroups.com
We use it, but due to working with a legacy schema we've had to make some internal changes to it to ensure we get decent go structures.

You can see the sort of things we've really quickly hacked into it, not had time to upstream, here:
https://github.com/stevenh/xo/commits/mysql-primary-keys

Key ones include:
* Multiple column primary keys for MySQL.
* Small and tiny for MySQL.
* Field tags for autoinc, default and primary key.
* Escape support for MySQL.
* Remapping support.

We also use a custom set of templates.

Its a sound library and covers the basics but we still end up rolling a lot of had written SQL.

    Regards
    Steve


On 20/07/2017 05:04, Nate Finch wrote:
We're thinking of dropping gorm and switching to plain old database/sql... but I don't really want to generate all that boilerplate myself.  xo looks like it does a reasonable job of generating the boilerplate for you, so I was wondering if anyone had any experience using it in production.  Gotchas, etc.

-Nate

Nate Finch

unread,
Jul 20, 2017, 1:22:49 PM7/20/17
to golang-nuts, nate....@gmail.com
The main reason is to avoid magic.  My past experience with ORMs has been that they make easy things easier and hard things harder.  Once you start leveraging relational bits, they become incredibly unwieldy to actually use.  They also tend to generate wildly suboptimal SQL and rely on a lot of reflection that is just slow.

Michael Banzon

unread,
Jul 20, 2017, 4:10:15 PM7/20/17
to Nate Finch, golang-nuts
I see your point.

I might checkout going bare database/sql on one of my smaller projects to get a feel for it - now that I’ve been thinking about it it strikes me that I’ve actually never tried database stuff on Go without gorp/gorm etc.

-- 
Michael Banzon




Reply all
Reply to author
Forward
0 new messages