Intro

On the 5th of February 2023, I had the privilege of giving a talk at the PostgreSQL devroom during FOSDEM 2023 titled “When it all GOes right.” My talk focused on the process of creating programs in the Go language using a PostgreSQL database. It was an incredible opportunity to share my insights and experiences with fellow open-source enthusiasts from around the world, and to discuss the latest trends and developments in this rapidly evolving field. In this blog post, I’ll provide the key takeaways and links to the sources to explore some of the most exciting innovations in Go and PostgreSQL programming. Slides in PDF format are available on the FOSDEM PgDay 2023 event page.

YouTube

By loading the video, you agree to YouTube’s privacy policy.
Learn more

Load video

Go Developer Surveys

Top products written in Go

These are well-known products:

  • Kubernetes (K8s) – production-grade container management
  • OpenShift – a family of containerization software products
  • Moby – a collaborative project for the container ecosystem
  • Hugo – the world’s fastest framework for building websites
  • Grafana – observability and data visualization platform
  • frp – a fast reverse proxy to expose a local server behind a NAT
  • Gogs – painless self-hosted Git service
  • Etcd – distributed reliable key-value store
  • Caddy – fast, multi-platform web server with automatic HTTPS

These are PostgreSQL-related:

  • CockroachDB – a cloud-native distributed SQL database;
  • pgweb – a сross-platform client for PostgreSQL databases;
  • stolon – a cloud native PostgreSQL manager;
  • postgres operators by Zalando and by Crunchy;
  • wal-g – archives and restoration for Postgres;
  • pgcenter – top-like admin tool for troubleshooting Postgres;
  • pgwatch2 – PostgreSQL metrics monitor/dashboard;
  • pg_timetable – advanced scheduling for PostgreSQL;
  • pg_flame – a flamegraph generator for EXPLAIN output.

You can find more on Awesome Go.

IDE’s and tools

According to the developer surveys, the most highly-preferred editors for Go code are:

I highly recommend using the following tools in your work:

  • VSCode with the official vscode-go plugin;
  • mfridman/tparse – summarizes go test output with color tables;
  • golangci-lint – fast linters Runner for Go;
  • Tabnine – the AI code completion tool;
  • GoReleaser – deliver Go binaries as quickly and easily as possible;
  • PostgreSQL – most advanced object-relational database;
  • gitpod.io – container-based ready-to-code developer environments.

There was a question about generating Go structures and code based on PostgreSQL objects. I highly recommend trying the kyleconroy/sqlc package for this purpose.

PostgreSQL drivers

Read go-database-sql.org to have an idea about idiomatic way to use a SQL, or SQL-like, database in Go is through the database/sql package.

lib/pq – pure Go Postgres driver for database/sql is currently in maintenance mode.

For new projects, you want to use jackc/pgx.

Testing

There are three ways to test your application’s PostgreSQL-specific functionality:

CI/CD

For every one of my projects, I have at least these 5 GitHub Actions workflows enabled:

  • Dependabot – maintains repository’s dependencies automatically;
  • CodeQL – action runs analysis engine to find security vulnerabilities;
  • Build & Test – action runs on each pull request, or manually;
  • Release – action runs on new tag, publishes release;
  • Docker – action runs on every commit, publishes Docker images.

Finally

In conclusion, FOSDEM 2023 was an inspiring experience. I want to highlight the importance of clean code, open-source collaboration, and, of course, community. I hope these takeaways will encourage you to explore the world of open-source programming. Thank you for joining me on this journey, and I look forward to continuing to explore this exciting field with you!

Meanwhile check out these projects written in Go and maintained by the CYBERTEC PostgreSQL international team:

  • pg_timetable – an advanced scheduler for PostgreSQL;
  • vip-manager – a virtual IP manager based on state kept in etcd or Consul;
  • pgwatch2 – a flexible self-contained PostgreSQL metrics monitoring/dashboarding solution.

In order to receive regular updates on important changes in PostgreSQL, subscribe to our newsletter, or follow us on Twitter, Facebook, or LinkedIn.