Hey gophers, I'm excited to announce sqlc, my project for turning SQL into type-safe Go. With sqlc, the following SQL:
CREATE TABLE authors ( id BIGSERIAL PRIMARY KEY, name text NOT NULL, bio text ); -- name: GetAuthor :one SELECT * FROM authors WHERE id = $1 LIMIT 1; gets turned into this Go package db import ( "context" "database/sql" ) type Author struct { ID int64 Name string Bio sql.NullString } const getAuthor = `-- name: GetAuthor :one SELECT id, name, bio FROM authors WHERE id = $1 LIMIT 1 ` type Queries struct { db *sql.DB } func (q *Queries) GetAuthor(ctx context.Context, id int64) (Author, error) { row := q.db.QueryRowContext(ctx, getAuthor, id) var i Author err := row.Scan(&i.ID, &i.Name, &i.Bio) return i, err } I wrote up a larger piece about why I started the project here: https://conroy.org/introducing-sqlc. It includes a guided walk through and more example code. Happy to answer any questions you have about the project. Cheers, Kyle -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/2d87986d-fc00-4fc2-afa3-352dedc2f9b7%40googlegroups.com.