Go is a statically-typed language with syntax similar to C that was designed to be efficient, reliable, and easy to use. Go is commonly used for building web servers, networking tools, and distributed systems. Go is also known for its fast compilation times, making it an excellent choice for building large-scale applications.
While Go is primarily used for building command-line applications, you can also build graphical user interfaces (GUIs). Several third-party GUI packages are available to create visually appealing and user-friendly GUIs. In this article, we’ll look at some of the best GUI frameworks for Go.
A GUI framework also allows developers to create cross-platform applications that can run on different operating systems with minimal modifications. This is important for developers looking to target a wide range of users, regardless of their operating system. These packages provide tools that make creating and managing graphical elements easier, such as buttons, text fields, and menus. Additionally, these frameworks can provide an easy-to-use API and abstract away the complexities of GUI development.
The use of GUI frameworks also helps separate the application’s logic from the presentation, making the application more modular and maintainable. This article aims to overview popular third-party GUI development packages in Go. You’ll learn about the packages, features, and functionalities, from the GTK package to Qt, Fyne, and Walk packages.
GTK (GIMP Toolkit) is a multi-platform toolkit for building GUIs. GTK is written in C and has bindings for various programming languages, including C++, Python, C#, and Go. GTK3 helps create desktop applications for Linux and Unix-like systems and supports macOS. The GTK project supports themeable widgets, advanced layout management, accessibility support, and internationalization support, and the package is designed to be extensible to widgets.
The go-gtk package is a Go binding for the GTK toolkit. The package enables Go developers to use the GTK library in Go with similar features as the GTK library. The package is performant, well-documented, and actively maintained. The go-gtk package depends on the GTK library to function, and you’ll need to have GTK installed on your machine to build GUI applications in Go. Head to the installations page, where you can find instructions for your OS.
After installing the GTK, run this command in the terminal of your project’s working directory to install the go-gtk package:
go get github.com/mattn/go-gtk/gtk
Here’s how you can import the go-gtk package in your Go file:
import "github.com/mattn/go-gtk"
The go-gtk package is an excellent option for Go developers to create GUIs using the GTK+ toolkit. The go-gtk package provides a simple, easy-to-use API that makes it easy to take advantage of the complete feature set of GTK+ while maintaining performance.
Qt is a cross-platform application development framework widely used for developing desktop, mobile, and embedded systems. Qt provides a powerful, easy-to-use, and flexible C++ class library for building GUIs and other types of applications. Qt has a wide range of built-in widgets, including buttons, labels, list boxes, and more.
Qt also provides support for multiple platforms, from Windows to macOS, Linux, iOS, and Android. Qt also supports libraries for various languages, including C++, Python, and QML, with an event-driven model for creating highly responsive and interactive applications.
The qt package is a Go wrapper for the Qt library, providing a framework for creating cross-platform applications. The qt package offers many features and functions, including support for GUI components such as buttons, labels, and text fields.
The qt package wraps the Qt library (C++ based), and you’ll need to have the package installed and a C++ compiler for building and running your application. Head on to the Qt library installations page to install the Qt library to get started.
Run this command in the terminal of your project’s working directory to install the qt package:
go get -u github.com/therecipe/qt
Here’s how you can import the qt package in your Go files:
import "github.com/therecipe/qt"
Overall, the qt package provides a powerful and flexible tool for creating cross-platform applications, allowing developers to take advantage of the performance and ease of use of Go while also using the extensive functionality of the Qt library.
Fyne is an open source, cross-platform GUI toolkit written in Go. Fyne provides an easy-to-use API for creating modern, responsive graphical user interfaces that run on Windows, macOS, Linux, and mobile devices (iOS and Android).
Fyne uses the GPU of machines to accelerate rendering, making the package suitable for building high-performance applications with dynamic layouts. The package provides clipboard support, gesture events, accessibility and internationalization, and cross-platform file and directory dialogs.
Fyne’s API is designed to be easy to use, emphasizing a consistent and familiar experience across all platforms. The package includes a variety of widgets, such as buttons, labels, text inputs, and more, which can be quickly composed to create complex UIs.
The fyne package is available on GitHub, and you can install it by running this command in the terminal of your project’s working directory:
go get -u github.com/fyne-io/fyne
Here’s how you can import the Fyne package into your Go files:
import "github.com/fyne-io/fyne"
Fyne is under active development and is gaining popularity in the Go community. The package is used in many open source and commercial projects due to its many features.
The walk package is a Go package for building GUI apps. Walk wraps the Windows API and provides a clean, high-level API for creating Windows apps in Go.
The walk package takes an event-driven approach where the app responds to user inputs and system events rather than running in a loop. The walk package also supports widgets and customized widgets for building user interfaces, such as buttons, labels, text boxes, and more, and layouts from grids, flow, and dock.
To install the walk package, run the following command:
go get -u github.com/lxn/walk
You must be running Windows to use the walk package since walk depends on the Windows GUI library. Now, here’s how you can import the walk package in your Go files:
import "github.com/lxn/walk"
The walk package is flexible and customizable, providing a high-level, easy-to-use API for creating professional-looking, feature-rich Windows apps with minimal effort.
Gio is an open source Go project that provides Go libraries for building graphical user interfaces (GUIs). Gio helps Go developers build efficient, fluid, and portable GUIs across all major platforms.
The tool combines bleeding-edge 2D graphics technology with the flexibility of the immediate mode graphics paradigm for creating a compelling and consistent foundation for GUI application development. The Gio project’s primary focus is providing a lightweight and efficient medium for building cross-platform GUIs that can run on various operating systems. These include WebAssembly, Android, tvOS, FreeBSD, OpenBSD, Windows, macOS, and Linux.
The gio package supports various widgets from buttons to labels, text fields, layout and styling, and touch and gesture input support. Gio also includes an efficient vector renderer based on the pathfinder project implemented on OpenGL ES and Direct3D 11. The project is migrating towards an even more efficient compute-shader-based renderer built on piet-gpu.
Gio is designed to work with a few dependencies, and the tool depends on several platform libraries for window management and GPU drawing. Run this command in the terminal of your GOPATH
to install the Gio package:
go install gioui.org/cmd/gogio@latest
You can import the various sub-packages in the Gio package depending on your use case, like so:
import ( "gioui.org/app" "gioui.org/font/gofont" "gioui.org/io/system" "gioui.org/layout" "gioui.org/op" "gioui.org/text" "gioui.org/widget/material" )
Gio is an excellent option for developers who build cross-platform GUI applications with Go. Its lightweight and efficient design, simple and easy-to-use API, and support for various widgets and layout options make it easy for developers to build visually appealing and responsive GUI interfaces.
When considering a GUI package for a project, it is essential to consider the project’s requirements, such as the target platform, desired look and feel, and performance needs.
Here are a few points about the packages you may want to consider:
Here’s a comparison table comparing the packages based on popularity, production readiness, and compatibility:
Package name | Popularity (GitHub stars) | Production-Ready | Compatibility |
---|---|---|---|
go-gtk | 1.9k | Yes đź‘Ť | Windows and Linux |
fyne | 19.3k | Yes đź‘Ť | Android, iOS, Windows, macOS, and Linux |
qt | 9.6k | Yes đź‘Ť | Android, iOS, Windows, macOS, and Linux |
walk | 6.3k | Yes đź‘Ť | Windows |
gioui | 1.1k (main GitHub repository mirror) | Yes đź‘Ť | WebAssembly, Android, tvOS, FreeBSD, OpenBSD, Windows, macOS, and Linux |
The go-gtk and fyne packages are suitable for desktop applications, while gioui is good for mobile and desktop applications. The qt and walk packages are good choices for cross-platform and Windows-specific applications, respectively.
You’ve learned about the essence of using Go for developing GUI applications, and you learned about the popular go-gtk, fyne, walk, qt, and gio third-party packages that facilitate cross-platform GUI development in Go. You also got a comparison of the GUI packages to help you choose a package for your project.
You can also build command-line applications in Go. To learn more, check out this article on using Cobra to build a CLI accounting app. The Cobra package is notable for building sophisticated CLI apps from Hugo to Docker and Kubernetes.
Install LogRocket via npm or script tag. LogRocket.init()
must be called client-side, not
server-side
$ npm i --save logrocket // Code: import LogRocket from 'logrocket'; LogRocket.init('app/id');
// Add to your HTML: <script src="https://cdn.lr-ingest.com/LogRocket.min.js"></script> <script>window.LogRocket && window.LogRocket.init('app/id');</script>
Would you be interested in joining LogRocket's developer community?
Join LogRocket’s Content Advisory Board. You’ll help inform the type of content we create and get access to exclusive meetups, social accreditation, and swag.
Sign up nowCompare Prisma and Drizzle ORMs to learn their differences, strengths, and weaknesses for data access and migrations.
It’s easy for devs to default to JavaScript to fix every problem. Let’s use the RoLP to find simpler alternatives with HTML and CSS.
Learn how to manage memory leaks in Rust, avoid unsafe behavior, and use tools like weak references to ensure efficient programs.
Bypass anti-bot measures in Node.js with curl-impersonate. Learn how it mimics browsers to overcome bot detection for web scraping.
2 Replies to "Best GUI frameworks for Go"
Insightful
The maintainer of the qt package for Go hasn’t had any Github activity since 2020. No PRs are being merged. I think it would be best to delist it here, or at least provide a warning (and maybe make it red and bold).