Electron UI for Golang Program?
Asked Answered
S

7

31

I'd like to make a GUI in Electron for a Desktop Application written in Go (currently it's a command line tool).

What's the convention for communicating between the Electron and Go processes?

Would simply using the Go binary as an API work? Some sort of websocket communication?

Scenarist answered 30/4, 2016 at 23:14 Comment(0)
F
15

The interaction of an application written in electron with its backend is exactly like a Web browser, therefore you have the same options (Web Api, Web Sockets, Ajax, etc.)

Fritz answered 30/4, 2016 at 23:29 Comment(1)
I decided to use github.com/googollee/go-socket.io for the backend, and normal socket.io on the frontend. Thanks!Scenarist
G
20

You can use go-astilectron it allows you to build cross-platform GUI apps with GO and HTML/JS/CSS (powered by Electron) (disclosure: I'm the author)

Genital answered 29/4, 2017 at 9:14 Comment(0)
F
15

The interaction of an application written in electron with its backend is exactly like a Web browser, therefore you have the same options (Web Api, Web Sockets, Ajax, etc.)

Fritz answered 30/4, 2016 at 23:29 Comment(1)
I decided to use github.com/googollee/go-socket.io for the backend, and normal socket.io on the frontend. Thanks!Scenarist
O
15

You can execute your command line app from your Electron app via child_process.spawn and communicate with it via stdin/stdout.

Oval answered 1/5, 2016 at 6:9 Comment(0)
E
6

I've been looking exactly on how to run ElectronJS backend with Go to build a native desktop application.

you can use extraResources with process.resourcesPath variable to get into the Resources folder. and execute your binary. its not very recommended though.

Other option to use: https://github.com/wailsapp/wails

Its very lightweight and can export your app to MacOS and Windows.

Eboni answered 19/5, 2021 at 9:44 Comment(0)
B
4

Murlock Is an Electron wrapper for Golang to make it easy for this kind of app for Mac. They're working on Windows and looking for contributions for the other platforms.

Boleslaw answered 8/2, 2017 at 20:35 Comment(2)
Nice project, but I don't think it is a wrapper for Electron. The mac version uses WebKit. The windows version uses EdgeHTML.Melisa
Murlock is not a Electron wrapper. It's simply a Go package to build UI with html and css. But it looks like a very interesting project!Fermat
C
4

Similarly to Murlock, may I dare to suggest Webview library. It's a thin wrapper over Webkit and MSHTML that runs on Windows 7+, MacOS, Linux and OpenBSD.

It is much smaller and easier than Electron. Also the resulting apps are smaller and less memory-hungry.

You may have a look at https://github.com/zserge/webview/tree/master/examples/todo-go for a Todo app example that compiles into a small standalone binary.

Confederate answered 24/10, 2017 at 17:52 Comment(0)
P
2

Checkout muon which is best described by their readme:

Muon is a lightweight alternative to Electron written in Golang in about ~300 LoC, using Ultralight instead of Chromium. Ultralight is a cross-platform WebKit rewrite using the GPU to target embedded desktop applications that resulted in a fast, lightweight, and low-memory HTML UI solution that blends the power of Chromium with the small footprint of Native UI.

I have not used it myself but it looks very promising!

Peadar answered 14/10, 2019 at 17:10 Comment(2)
But worth mentioning... Ultralight has a very aggressive pricing model for anything above "indie" developers. "While muon itself is MIT licensed, Ultralight is not."Serdab
For anyone looking at this in 2021, Muon has stopped maintaining since 2019.Knuth

© 2022 - 2024 — McMap. All rights reserved.