- Using the Wails GUI framework:
Wails
is a framework that enables you to write desktop apps using Go and web technologies. This in itself allows you to immediately apply all your acquired knowledge if you come from the Web world, that's why we can consider it a lightweight and fast Electron alternative for Go. You can easily build applications with the flexibility and power of Go, combined with a rich, modern frontend. Wails supports cross-compilation for various platforms, native menus, dialogs and theming, use of various JavaScript frameworks for building the frontend, live development mode using the power of Vite, and a powerful CLI to easily create, build, and package applications, among many other features. - Using
CloverDB
as a database:CloverDB
is a lightweight, embedded NoSQL database, designed to be simple and easy to maintain, thanks to its small code base, which we have chosen for application data persistence. Although, perhaps, the main advantage of this DB is that it is written in pure Golang and that it has a simple and intuitive API. The fact that it is written in pure Golang (without any dependency on libraries in another language, such asC
in the case ofSQLite
) allows you to avoid compiling withCGO
enabled, which is useful when compiling forWindows
. WhileCloverDB
allows easy export/import to/fromJSON
files, we have chosen to export the data to a binary format that can only be read by the application itself. - Using the SevelteJS frontend framework:
Sevelte
is a UI framework to let you write breathtakingly concise components that do minimal work in the browser. It is the framework mainly recommended for the creation of GUIs by the creators ofWails
given its ease of use, mainly in combination withTypeScript
. Although the Wails CLI installsSvelte3
by default, we have chosen to useSvelte5
here, which allows the use of either therunes
feature or the legacy system. - Using the svelte-spa-router library: although the official Svelte routing library is
SvelteKit
it is a bit overkill for the purposes of a desktop application that only aims to swap different views in response to user interaction. Instead we have used (see here) the popularsvelte-spa-router
library which is insanely simple to use, and has a minimal footprint. - Using the svelte-i18n library: svelte-i18n helps you localize your application using the reactive tools offered by
Svelte
. This library simplifies translation management using JSON files that help your application easily switch between different languages. In fact, the use of theWails
framework, which uses web interfaces, greatly facilitates some common tasks in desktop applications, such as their translation. Some online tools can help you with the translation ofJSON
files, such asTranslate i18next JSON resources/files
. - Using the sweetalert2 library: As the documentation for this library says "a beautiful, responsive, customizable and accessible (WAI-ARIA) replacement for JavaScript popups with zero dependencies". Here we basically use it to create modals/dialog boxes easily and quickly. It is up to the user to decide whether the result makes the application "look excessively similar" to a website.🤦
- Using
Tailwindcss
and its plugindaisyUI
: to allow you to style your application easily and quickly, and they also integrate seamlessly withSvelte
andWails
.
If you don't have Go, you can download the appropriate executable for your platform from here. Once unpacked, you can place it in the folder where your system normally stores executables (although you could place it in any directory). Then, you just need to update the system PATH with that address. For Linux, if you run the Makefile ("make user-install" to install to ~/.local/, or "make user-uninstall" to uninstall) you can easily install the application for the user or on the system ("sudo make install/uninstall").
If you already have Go installed (Go 1.20 or higher is required) and you want to modify code and/or build the binaries yourself, you will need to meet some prerequisites. You will need to consult the Wails
documentation to install the dependencies required by your platform (see here). Obviously, for compiling and installing frontend dependencies you also need to have NodeJs
installed which comes with the npm
package manager (npm (Node 15+)).
Wails
has the advantage of having a powerful CLI
that makes it very easy to generate the scaffolding to start an application, to develop with hot reload, and to build and package it into a single binary, in addition to the already mentioned cross-compilation for different platforms. So it is highly recommended to install it with the command:
$ go install github.com/wailsapp/wails/v2/cmd/wails@latest
Note
While the wails init -n "myproject" -t svelte-ts
command scaffolds a new project using Svelte3
, we've already mentioned that this application uses Svelte5
. If you're interested in that option, as long as you have the Wails CLI
and NPM
installed, you can scaffold your projects using this bash script I've created to automate that migration.
From this point on, if you have met the above requirements, you can clone the repository and run the following command in the project folder to start the application in development mode:
$ wails dev
This allows hot reloading by saving modified code and monitoring the results, both in the launched application and in a browser (at the address http://localhost:34115
). Right-clicking on the opened application window allows you to choose between several options, including opening a development tools panel equivalent to the devtools of the Chrome
browser.
Finally, if you want to build the application executable by packaging everything, including the application icon and all assets (fonts, images, etc.) just run the command:
$ wails build
This will build the binary into the build/bin
folder. However, for choosing other build options or performing cross-compiling, you may want to take a look at the Wails CLI documentation.
Note
As mentioned above I have created for the Linux version a compressed .tar.xz
file with the application and a Makefile that acts as an 'installer' that installs the executable, a desktop entry
to create an entry in the Start Menu
and the corresponding application icon. For the Windows version, the binary is simply compressed as a .zip
inside a folder called dist/
. If you prefer, you can generate both compressed files by running the project's Makefile
: "make create-bundles"