SQL Query Strategy for complex structs

This page summarizes the projects mentioned and recommended in the original post on reddit.com/r/golang

Our great sponsors
  • InfluxDB - Access the most powerful time series database as a service
  • SonarLint - Clean code begins in your IDE with SonarLint
  • SaaSHub - Software Alternatives and Reviews
  • sqlc

    Generate type-safe code from SQL

    https://github.com/kyleconroy/sqlc will generate Go structs for inputs & outputs of Postgres queries, that'll get you type safety.

  • pgx

    PostgreSQL driver and toolkit for Go

    Hi fellow Gophers, I have a question involving both (Postgre-) SQL and Go. For a hobby project, I so far have used plain SQL with some additional filtering logic and pgx to to retrieve rows and mapped these rows to structs manually. This worked quite well as the types were rather simple and only involved 1-3 SQL tables.However, I now do have a more complex struct type with 10 underlying SQL tables including some nested structs and slices. I feel that my prior strategy of plain SQL query strings doesn't scale to retrieve data from the SQL DB even for this moderatly complex struct type.

  • InfluxDB

    Access the most powerful time series database as a service. Ingest, store, & analyze all types of time series data in a fully-managed, purpose-built database. Keep data forever with low-cost storage and superior data compression.

  • jet

    Type safe SQL builder with code generation and automatic query result data mapping

    Check https://github.com/go-jet/jet. It supports arbitrary nested structs. Also it works well with pgx, as a driver.

  • bun

    SQL-first Golang ORM (by uptrace)

    bun and go-pg both seem to work fairly well for these kind of purposes.

  • go-pg

    Golang ORM with focus on PostgreSQL features and performance

    bun and go-pg both seem to work fairly well for these kind of purposes.

  • SQLBoiler

    Generate a Go ORM tailored to your database schema.

    didn’t know jet, any major difference with https://github.com/volatiletech/sqlboiler?

  • scany

    Library for scanning data from a database into Go structs and more

    I like to use pgxscan from https://github.com/georgysavva/scany

  • SonarLint

    Clean code begins in your IDE with SonarLint. Up your coding game and discover issues early. SonarLint is a free plugin that helps you find & fix bugs and security issues from the moment you start writing code. Install from your favorite IDE marketplace today.

  • go-formatter

    A curated list of awesome Go frameworks, libraries and software

    https://github.com/avelino/awesome-go is good place to start.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts