JavaScript is one of the most widely used programming languages for creating interactive web interfaces. Svelte is a modern, reactive JavaScript framework that compiles your code into highly efficient, minimal runtime JavaScript. It allows you to build powerful and fast web applications with less overhead compared to other frameworks.
Go (Golang) is a performant, statically typed language designed for simplicity and efficiency, ideal for backend development. It was created by Google in 2006 with modern computing in mind, including multicore processors, cloud-based infrastructure, and networked systems. Go’s concurrency model (goroutines and channels) and its straightforward syntax make it an excellent choice for building scalable, high-performance software.
Wails allows you to build desktop applications for Windows, macOS, and Linux using Go for the backend logic and modern web technologies (like Svelte, React, Vue, or plain JavaScript/HTML/CSS) for the frontend. It essentially bridges Go to the frontend, so your Go code can directly interact with your web UI. This makes Wails ideal for developers who prefer Go for server-side or business logic, but want the convenience and flexibility of a JavaScript-based frontend.
Below are instructions for installing from scratch on Windows and macOS, ensuring you have all prerequisites to work with Wails 2.10.
You will need the following:
-
Git
- Windows: Download Git for Windows and run the installer.
- macOS: Git is typically installed by default on macOS. If not, install Xcode Command Line Tools or use Homebrew (
brew install git
).
-
Go (1.18 or newer recommended)
- Windows: Download Go for Windows and run the installer. Follow the prompts.
- macOS: Download Go for macOS and run the installer, or use Homebrew (
brew install go
).
-
Node.js (LTS version recommended) & npm
- Windows: Download Node.js for Windows and run the installer.
- macOS: Download Node.js for macOS and run the installer, or use Homebrew (
brew install node
).
-
Wails CLI (2.10 or newer)
You can install Wails via:go install github.com/wailsapp/wails/v2/cmd/wails@latest
Make sure your
GOPATH/bin
(or the equivalent Go bin directory) is in yourPATH
.
- Git:
git --version
- Go:
go version
- Node:
node -v
- npm:
npm -v
- Wails:
wails version
-
Clone the Project
git clone https://github.com/jorgec/GoCalc
Then navigate into the project directory:
cd GoCalc
-
Install Go Dependencies
In the
GoCalc
folder (the root of the project), run:go mod tidy
-
Install Wails CLI
Ensure you have Wails (2.10 or newer) installed:
go install github.com/wailsapp/wails/v2/cmd/wails@latest
-
Install Frontend Dependencies
Navigate to the
frontend
folder:cd frontend npm install
-
(Optional) Return to Project Root
cd ..
- Make sure the folder where Go installs executables (usually
%USERPROFILE%\go\bin
) is in yourPATH
. - If
wails
is not recognized as a command, open a new terminal or command prompt after adjusting your systemPATH
.
- Ensure you have a recent Go version installed (1.18 or above).
- If
wails
is not recognized, ensure$(go env GOPATH)/bin
is in yourPATH
. - You can manage installations easily using Homebrew.
- I'm assuming that if you're on Linux, it would be pretty condescending for me to give you any instructions :)
From the project root directory (where your main.go
and go.mod
reside), run:
wails dev
This does two things:
- Spins up a Vite development server that automatically hot-reloads frontend changes.
- Provides a dev server on http://localhost:34115, where you can open your browser and access Go methods from devtools if desired.
You can generate a password
file using the bundled bash
script:
./passgen.sh 'password'
Note that the password parameter should be enclosed by single quotes.
For Windows, you can use the PowerShell script passgen.ps1
or the batch file passgen.bat
To build a redistributable, production-mode package, run:
wails build
After the build completes, you will have a cross-platform desktop application in the build/bin
folder (depending on your configuration and OS). Distribute it to users just like any other native application.
For MacOS, copy the generated password file to the App
package, for example:
cp password "build/bin/GoCalc.app/Contents/MacOS/"
For Windows, just make sure the password file is in the same location as the executable