Introducing Go Inline-pgFormatter: Streamlining SQL Formatting in Go

January 17, 2024

Alex Branton and Dr. Dmitriy Richard Starson

The need for a new SQL formatting tool

At Passio we are committed to growing the developer community and helping developers to rapidly build and deploy AI powered applications. In our daily work we are often encountering inefficiencies and challenges with existing solutions and in some cases we are able to fix them with our tools - some commercial and some open and free. In our Passio AI Insights Series we are excited to share with the developer community lessons we are learning and tools we are releasing while building Passio. We will be sharing tutorials, explainer videos, developer interviews and live sessions focused on both our paid SDKs and free tools we are opening up.

In this installment we are excited to share a story of Go Inline-pgFormatter - a free tool created by our Lead Backend Engineer, Alex Branton. This tool is available for free as a VS Code Extension. It is already used by nearly 3000 developers to save time and make SQL formatting in Go files effortless. Here is Alex’s story of why we developed and released the tool.

As developers we are constantly looking for ways to increase productivity and enhance code quality. While working with Go, we've often found ourselves grappling with the manual formatting of SQL strings. This process not only consumes developer time but also introduces inconsistencies across the codebase.

We looked for suitable solutions online but discovered a glaring gap – no existing extension addressed that specific need. So Alex and several others on our team developed the Go Inline-pgFormatter extension for Visual Studio Code. We found this extension very helpful and started to use it consistently at Passio when working with Go and SQL.

The usefulness of the tool is obvious from the Before & After images below:

Before formatting
After formatting

Before Go Inline-pgFormatter, developers had to resort to manual, time-consuming formatting or just kept strings formatted, leading to code errors. With Go Inline-pgFormatter, formatting of raw-string SQL queries within Go files (particularly PostgreSQL style) becomes very easy and takes just a single command within VS Code environments.

Here's how it works:

  • Leveraging pg_format: The extension utilizes pg_format to format SQL strings enclosed in backticks, ensuring that queries are consistent and adherent to best practices.
  • Dependency on Perl: Perl must be installed on your system, as it is a dependency for the underlying formatting script.
  • Customization Options: Developers can tailor the formatting to their preferences through the extension settings, providing flexibility to meet specific project requirements.

We’ve been excited to see positive response from the community with approximately nearly 3,000 downloads since launch. If you’re one of the users, please give us a Like!

For those interested in integrating Go Inline-pgFormatter into their development workflow, we invite you to visit the Visual Studio Marketplace and the GitHub repository to get started. Your feedback, likes and comments would be highly welcome! We hope this tool and other tools we are releasing will help you!

Here’s the link: https://marketplace.visualstudio.com/items?itemName=passioinc.go-inline-pgformatter

You can install it in VS Code by Searching Extensions for Passio Pgformatter.

Happy coding! Let’s build the future of AI-powered apps together!

Try Our Products Today!

Grow your business with ready-to-use AI modules and AI/AR-driven experiences.