This issue features WAILS, a project that uses Go and Web technologies to build desktop applications.
Wails is a framework that helps you write desktop applications using Go and Web technologies. For the front end, use the Webview library. However, it uses the platform’s native rendering engine (currently Webkit for Linux and Mac, MSHTML for Windows). The front end is coded in HTML/Javascript/CSS, and the back end is pure Go. Through the binding mechanism, Go code can be exposed to the front end as a function that returns promises. The project compiles to a single executable file into which all resources are bundled. On Windows and MacOS, binaries can be bundled into platform-specific packages for distribution.
Note: The rendering engine is a WebView, not a bundled Web browser, so some “browser apis” will not be available for your application, such as localstorage. Most applications don’t need to use them, and if you still want to, you can use Go for most things.
Function
- Go
- Build UI interfaces with any front-end technology
- Quickly generate Vue, Vuetify, React front-end code for your Go app
- Expose the Go method to the front end with a simple bind command
- Using native rendering engine – no embedded browser
- Shared Event system
- Native File system dialog
- Powerful command line tools
- Across multiple platforms
Overview
- Wails
Wails is designed to minimize the differences between web technologies and Go. The front end is a Webview component, and you can use any common Javascript framework you like to develop the front end code and interact with the Go code inside. This is achieved through a shared IPC mechanism.
- IPC Overview
The IPC mechanism can run in two runtimes, one running in Javascript and one running in Go. They all provide a simple interface that relieves developers of the burden of dealing directly with IPC mechanisms.
The runtime shares common components that developers can interact with: bindings and events.
- Binding
The Wails application provides a way for you to (bind) exposed Go code to the front end. Using this method, you can bind any function or exposed structural method. At startup, Wails analyzes the bound functions/methods and automatically provides the equivalent functions in Javascript. Enables you to call the bound Go code directly from Javascript.
JavaScript wrap functions that handle all the complexity of calling Go code. You simply call the function using Javascript and receive a Promise. The binding Go code functionality handles all the complexity of the binding. If the call to the Go code completes successfully, the result is passed to the resolve function. If an error is returned, it is passed to the reject function.
- Event
Wails provides a unified event system, similar to Javascript’s native event system. This means that any event sent from Go or Javascript can be received by either party. Data can be passed along with any event. In this way, you can do simple things like let the background process run in Go and tell the front end to update the page.
Installation
- Installation command
The installation process is very simple, just run the following command:
go get -u github.com/wailsapp/wails/cmd/wails
After installation, the “wails update” command can be used for subsequent updates.
To get the latest pre-release with the latest features you can attach the -pre tag after it: wails update-pre.
To complete the setup, run the installation command wails setup and fill in your name and email address.
- Generate new project
Generate a new project using the initialization command wails init, select the default options.
- Build
Switch to the project directory cd my-project and build your project using the build command build command wails build.
If all goes well, you should have a compiled program in your local directory. If using Windows, use./my-project to run it or double-click myproject.exe.
Project presentation
WOMBAT
SURGE
MOLLY Purse
PORTFALL
RESTORIC
OPTIMUS Screenshot editor
—END—
Open Source protocol: MIT