Below are a bunch of commonly used packages and other tools for software development with Go. Go has excellent backwards and forwards compatability, so tools that haven’t been updated in a long time may still be a great choice. Unless otherwise noted, each tool listed here appears to me to be good enough at what it does that I don’t feel the need to look at alternatives.
If you’re new to Go, check out Learning Go.
Miscellaneous
import "github.com/joho/godotenv"
Load environment variables from .env files.
import "gopkg.in/natefinch/lumberjack.v2"
A log rolling package for Go. This can be used as the backend behind the Go standard library’s log/slog
package.
import "github.com/gorilla/websocket"
gorilla/websocket is a fast, well-tested and widely used WebSocket implementation for Go. It passes the server tests in the Autobahn Test Suite.
import "github.com/coder/websocket"
This WebSocket implementation is similar to Gorilla’s, but has different pros and cons.
import "github.com/markbates/goth"
Multi-provider authentication for Go.
go install github.com/a-h/templ/cmd/templ@latest
Create components that render fragments of HTML and compose them to create screens, pages, documents, or apps. Using templ with htmx is popular because it provides “many of the benefits of React with reduced overall complexity.” React can also be used with templ; see Using React with templ.
import "github.com/spf13/cobra"
A library for creating powerful modern CLI applications.
go install github.com/spf13/cobra-cli@latest
A tool for generating Cobra code made by the creators of Cobra.
import "github.com/spf13/viper"
A complete configuration solution for Go applications including 12-Factor apps. This was also made by the creators of Cobra.
Release Go projects as fast and easily as possible. There’s an official GitHub Action.
go install golang.org/x/tools/cmd/gonew@latest
A tool for instantiating new projects in Go from predefined templates.
go install github.com/air-verse/air@latest
Live reload for Go apps. I’m not interested in this, but I often see people new to Go ask if something like this exists.
Profiling and analysis
Package pprof writes runtime profiling data in the format expected by the pprof visualization tool.
go install golang.org/x/vuln/cmd/govulncheck@latest
A command-line tool that helps Go users find known vulnerabilities in their project dependencies.
Fast linters runner for Go. They have an official GitHub Action.
Practical nil panic detection for Go. Created by Uber, this static analysis tool can be installed and used locally, but is recommended to be used with a system like golangci-lint.
import "go.uber.org/goleak"
A goroutine leak detector created by Uber.
go install golang.org/x/tools/cmd/deadcode@latest
Find unreachable functions. This tool never accidentally says a reachable function is unreachable, unless it’s only called from code not written in Go. Its creators “run deadcode periodically on our projects, especially after refactoring work, to help identify parts of the program that are no longer needed.”
Database tools
import "github.com/jackc/pgx/v5"
A PostgreSQL driver and toolkit for Go. pgx is compatible with Go’s database/sql
package, but is slightly faster without it and has some Postgres-specific features that database/sql
doesn’t support. Postgres seems to be by far the most popular choice among the SQL technologies in Go outside of companies.
import _ "github.com/go-sql-driver/mysql"
A MySQL driver for Go’s database/sql
package.
go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
Generate type-safe code from SQL. This tool writes most of the database-related code you would have written anyways. One of many reasons sqlc is popular is because the use of ORMs in Go is strongly discouraged by almost all Go developers.
go install github.com/pressly/goose/v3/cmd/goose@latest
A database migration tool that supports SQL migrations and Go functions.
HTTP routers
In Go, it’s common to build web servers without using a framework because Go has several excellent routers.
The Go standard library’s net/http package has only the most basic features but is said to have the best performance.
Among third-party routers, chi and gorilla/mux are probably the most widely used. They are very similar. It appears gorilla/mux was more popular than chi in the past, but chi started catching up when gorilla/mux temporarily went unmaintained for a while. In online discussions, I almost always see people prefer chi over gorilla/mux. chi was implemented with a trie and gorilla/mux was implemented with regex.
import "github.com/go-chi/chi/v5"
import "github.com/gorilla/mux"
Here’s a big list of more routers.
HTTP frameworks
Although Go has many HTTP frameworks, below are just the ones I hear about often. Using a framework solves some problems, but also creates problems. For some use cases, they create more problems than they solve. Here’s a more complete list of HTTP frameworks.
import "github.com/labstack/echo/v4"
Echo appears to be the current most popular framework for new projects. It’s minimal, has a lot of middlewares available, and is one of the highest-performance frameworks. A commonly mentioned downside is that it’s different from Go’s standard library.
import "github.com/gofiber/fiber/v2"
Fiber’s design is based on Express, the JavaScript framework. It has the best performance out of all of Go’s widely used frameworks, but is specialized for specific use cases and does not support some things like detecting when the client has closed the site’s tab.
import "github.com/gin-gonic/gin"
Gin might be Go’s most widely used HTTP framework, but in online discussions, almost all Go developers recommend against using it for a wide variety of reasons. Some describe it as “bloated” or as a framework designed for developers that prefer Java. Gin uses custom interfaces that make it incompatible with much of the rest of the ecosystem. Apparently it also has poor performance and error handling.
Desktop app frameworks
Web-based GUI frameworks have way more features than native GUI frameworks, but may require more work to create simple GUIs.
go install github.com/wailsapp/wails/v2/cmd/wails@latest
Wails is a toolkit for creating web-based GUIs with Go. This is Go’s version of Electron or Tauri and is significantly more efficient than Electron.
import "fyne.io/fyne/v2@latest"
and go install fyne.io/fyne/v2/cmd/fyne@latest
Fyne is a toolkit for creating native GUIs with Go.