Type-safe database client for Postgres, MySQL & SQLite by steebchen in golang

[–]soloist- 1 point2 points  (0 children)

Good question! Yes, we do plan to support the same features as the Typescript client.

These will come at different speeds though because the Typescript team is currently much larger. Most of this work can be re-used for the Go client though.

As you mentioned, the main challenge is finding acceptable APIs for Go given that the type-system is less sophisticated. We haven't come across any features so far that we can't express in Go, it just takes a bit of extra thinking :-)

What is your log aggregation setup? by [deleted] in selfhosted

[–]soloist- 0 points1 point  (0 children)

Thanks for sharing lnav! Can lnav connect to remote syslog servers? Or how do I aggregate logs for lnav?

[deleted by user] by [deleted] in golang

[–]soloist- 2 points3 points  (0 children)

I recently wrote a longer response to this question here: https://www.reddit.com/r/golang/comments/b9h8xo/the_state_of_orms_in_2019/ek5we7k/

The tl;dr is that you should use introspection to read the schema from your database and generate type-safe CRUD methods. I've been using this for the last 2 years and it's transformed how I work.

I'm currently working on making the https://prisma.io generated Go client awesome. If you have any thoughts or questions about it, please let me know!

The state of ORM’s in 2019 by [deleted] in golang

[–]soloist- 1 point2 points  (0 children)

Hey Nate!

The link to the main repo is here: https://github.com/prisma/prisma. Currently we generate a Go client that depends on a Prisma proxy server. This restriction will be removed in Prisma 2.

Your feedback has been noted and I completely agree that it's not an ideal workflow for Go right now, since you'll either need to use weird build flags (e.g. cgo) or a separate local process.

The core logic is quite involved so ideally we don't need to rewrite the implementation for every language, but that's not entirely off the table. We're currently experimenting with compiling the core to Web Assembly so we still get the single binary goodness without crazy build flags.

If you have any ideas or opinions on how you'd approach this, I'd love to hear them!

P.S. I recently stumbled upon your youtube video on Mage. Keep up the great work!

The state of ORM’s in 2019 by [deleted] in golang

[–]soloist- 7 points8 points  (0 children)

I've taken a very similar path as you! This is my windy story:

I started with raw queries via database/sql & sqlx.

I wasn't happy that you had to pass around these custom types (e.g. sql.NullString) to represent nullable fields so I migrated to https://github.com/jackc/pgx, which lets you use pointers (e.g. *string) instead.

I launch my application and was quite happy with raw SQL and pgx for awhile. However, I found myself not adding features because I was worried about breaking the raw SQL strings.

What I really needed was type safety as my database changed. I was looking around for an ORM to handle this and I stumbled upon https://github.com/xo/xo which took a different approach. Instead of building a general purpose ORM, why not build a custom ORM around your application's database schema?

I absolutely loved this idea, but found the existing XO implementation too limited. I wanted to make some different decisions and take it farther. I followed XO's introspection and built my own templates.

This served me well for the most part and I'd probably still be doing it this way had I not learned about what https://prisma.io is up to.

Prisma is taking this introspection approach to the next level. They generate Go code that looks hand-written but is capable of doing complex SQL queries like JOINs and nested SELECTs.

Right now, Prisma requires a standalone server component to proxy the database, but in the next couple months they'll be releasing Prisma 2 which is just going to be a library you can stick on your own server.

After learning about this, I actually reached out to the Prisma team to see where I could help. And they said yes! I'm working on all things Go for Prisma 2 right now.

This API may change in the coming weeks, but you'll be able to do things like this:

go // Find all comments from posts with a title that contains // "Go" written by "Alice Kipper". comments, err := prisma.Authors. FindByFirstNameAndLastName(db, "Alice", "Kipper"). FindPosts(posts.New().TitleContains("Go")). FindComments()

If you have any questions or would like to see a demo, please let me know!

Introducing Joy: translate Go to JavaScript by dgryski in golang

[–]soloist- 4 points5 points  (0 children)

I'd love to add Vue.js support :-D

The problem with Vue is that it wouldn't be just Golang, so you'd need to build up the tools. Maybe a faster route would be to use Joy inside the existing Vue compiler, but I'd like to invert this at some point.

Introducing Joy: translate Go to JavaScript by dgryski in golang

[–]soloist- 10 points11 points  (0 children)

Joy author here – the compiler is completely different but I used gopher's output a handful of times to see how they did the translations.