[ANN] astilectron - Build cross platform GUI apps with GO and Electron (HTML/JS/CSS)

1,103 views
Skip to first unread message

Asticode

unread,
Apr 25, 2017, 3:54:22 PM4/25/17
to golang-nuts
Hi everyone,

I'm happy to announce astilectron, a GO library to build cross platform GUI apps in HTML/JS/CSS: https://github.com/asticode/go-astilectron

I needed a way to build a cross platform GUI app in GO but none of the projects out there were meeting my needs (they were either only MacOSX-compatible or not maintained anymore). At the same time, I knew about Electron which is cross-platform and well maintained. So I did the maths and took a shot at creating a ligthweight library that could rely on Electron and be available in GO.

I've started it this week-end so this is still in beta but in a nutshell, here's what it already does:

- on start it provisions the necessary dependencies (electron and a custom electron app I've made in NodeJS that provides an API over TCP). This means that worst case scenario it downloads the distributions and unzips them. Best case scenario (and thanks to the possibility of setting your own Provisioner) you can embed the distributions in your binary using go-bindata and only unzip them if they're not already set up.
- then you're good to go and can create windows and interact with them: move, resive, maximize, close, etc.
- each window is a browser therefore you can either load static .html files, a remote URL or the local GO server you've just started :D
- you can communicate between your GO app and the javascript in you server
- did I mention this is cross-platform? :D

Here's the architecture of the project:

+-------------+    TCP    +---------------------+    IPC   +---------------------+
+ your GO app |<--------->+ custom Electron app +<-------->+ win1: (HTML/JS/CSS) +
+-------------+           +---------------------+     |    +---------------------++
      |                             |                 +---->+ win2: (HTML/JS/CSS) +
      |         +----------+        |                    |  +---------------------++
      +---------+ Electron +--------+                    +-->+ win3: (HTML/JS/CSS) +
                +----------+                                 +---------------------+

I'd like to use this beta version to see if people are interested in that sort of project. If so, I'll dedicate more hours to add more features. Let me know in the comments section.

Of course I welcome any kind of contributions, may it be finding bugs or proposing enhancements.

Long live Golang!

Cheers
Asticode

Tyler Compton

unread,
Apr 25, 2017, 7:59:49 PM4/25/17
to Asticode, golang-nuts
I gave the examples a run and I can confirm it works very well on Linux. Thank you for making this! Leveraging Electron as it is makes a lot of sense.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mhh...@gmail.com

unread,
Apr 27, 2017, 5:33:10 AM4/27/17
to golang-nuts
I like it too, i'm only worried by the size of the app once everything it setup.

I wonder if its not possible to have something smaller,
obviously with less capabilities.

imho, i m interested mostly in window positioning and decoration.
Communication is less interesting to me as i can work with http apis, or so.

any ideas ?

Asticode

unread,
Apr 27, 2017, 8:12:31 AM4/27/17
to golang-nuts
I do agree with you regarding the size of the app once everything is setup.

Honestly chosing Electron is more a choice by default than anything else.

imo the chosen project should:

- be cross platform
- be well maintained
- allow creating non-native looks through HTML/JS/CSS since I think it's the easiest for the most of us

Here's a list of what I've tried so far:

- https://github.com/andlabs/ui : drawbacks are it has limited features, force you to have a native look and can't do things like capturing the "Enter" key event in an input box
https://github.com/miketheprogrammer/go-thrust : drawback is it's not maintained anymore
https://github.com/alexflint/gallium : drawback is it's not cross-platform (only MacOSX last time I checked)
https://github.com/murlokswarm/app : drawback is it's not cross-platform (only MacOSX too)
- https://github.com/arvitaly/gopherjs-electron : drawback is it's not maintained anymore
- https://github.com/rrohrer/go-electroncontrol : drawback is it's not maintained anymore
- https://github.com/nodekit-io/nodekit : drawback is it's not maintained anymore

As you can see none of them meet the 3 requirements.

Which leaves us with Electron which is cross platform, well maintained and allow creating non-native looks through HTML/CSS/JS.

If there are other projects I've missed, feel free to let me know, once again chosing Electron is more of a choice by default than anything else.

PS : if you're only interested in window positioning and decoration, and don't care about dealing with HTML/CSS/JS I recommend using https://github.com/andlabs/ui which is an awesome project!

Asticode

unread,
Apr 29, 2017, 4:49:49 AM4/29/17
to golang-nuts
Let me add one more project to the list:

- https://github.com/therecipe/qt: like https://github.com/andlabs/ui it forces you to have a native look and it seems overly complicated to embed the QT library in the binary

mhh...@gmail.com

unread,
Apr 29, 2017, 7:46:40 AM4/29/17
to golang-nuts
Hey thanks for this detailed answer.

We are in line about what we d like to get from such package,
lightness, efficiency, handy.

I ll just fix a misunderstanding, about my previous question,
I m totally adept of html based technologies for the GUI,
until electron came out, there were no other possibilities
to consume a desktop web gui other than using one of the
provided browser on the target system.

Electron came in and provided the missing driver,
between the gui and its container.

It also turned a classical browser interface, into a gui host,
by getting ride of all specialties of a browser.

Although, electron is unfortunately super heavy,
so in regards of the efficiency i expect,
i m still using regular target systems browsers to run such app.

What i'd like very much is a driver to invoke a browser on the host,
like i d do with `xdg-open`, but that would let me define size and positioning
of the window container, and let me add some options to disable
some features of the browser (no url bar, no regular menus ect)

It is really much like `window.open` directed towards
the desktop rather than the website being browsed.

I m not low level, i m not sure if that is possible, or how,
i m suspicious in the sense i guess someone would have
already done that instead of electron/nightmare things,
i just don t know.

Nyah Check

unread,
Apr 29, 2017, 8:07:11 AM4/29/17
to mhh...@gmail.com, golang-nuts
Awesome, will definitely check it out.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
"The heaviest penalty for declining to rule is to be ruled by someone inferior to yourself." --Plato

Konstantin Khomoutov

unread,
Apr 29, 2017, 10:17:52 AM4/29/17
to Asticode, golang-nuts
On Sat, 29 Apr 2017 01:49:49 -0700 (PDT)
Asticode <asti...@gmail.com> wrote:

> - https://github.com/therecipe/qt: like https://github.com/andlabs/ui
> it forces you to have a native look
[...]

It may be just me, but actually a virtue of "having a native look" is
one of the best selling points of a cross-platform UI toolkits.

Some developers appear to put much effort into "skinning" their apps
(old farts like me would remember how this plagued media players of the
nineties) completely fogretting about two points:
- Having a greatly-looking UI without the work of a trained designer
and testing it on focus groups is futile, and the end result is almost
always crappy (that is, to everyone except the obsessed creator).
- Most of the time users just do not give any special shi^Wcare about
your program -- instead considering it just a piece in their toolbox,
and quite often using it merely because it sucks less that its
alternatives, not because they love it in any special way.
And in this case, obviously, the principle of the least WTF for the
users is paramount: all the apps in their toolbox should look and
behave in the uniform way -- the way which is native to the user's
platform.

Asticode

unread,
Apr 29, 2017, 10:48:42 AM4/29/17
to golang-nuts, asti...@gmail.com
More often than not the obsessed creator will have the last say and will discard what the trained designer and results of the focus groups tests have to say unless they agree with him/her :D Hence the need for a more flexible solution.

But you have a good point.

However I still see at least 2 reasons why native looks could be a limit:

- This me belief that more developers know what are their options when making some HTML/JS/CSS than when dealing with "native looks" (panels, comboboxes, etc.) since most developers come from a Web background. May it be good or bad is not the point here, but I do think that it's more intuitive and easier for developers to make a UI using HTML/JS/CSS than using native components. That's not true for everyone but I think that's true for the majority. For the ones that feel more comfortable without any HTML/JS/CSS then there are plenty of great options out there and once again I can't recommend enough https://github.com/andlabs/ui
- Some simple stuff as simple as capturing the "Enter key was pressed in the input box" event somewhat can't be done using native libs such as https://github.com/andlabs/ui. In my case that was dealbreaker.

이현수

unread,
Jul 27, 2021, 1:57:07 PM7/27/21
to golang-nuts
Thanks for the good work!
Recently, I'm working on making a desktop app with astilectron. Now I'm going over the code of go-astilectron-demo. It works perfectly meeting my needs.
The question is that
How can I debug the code when the bundler is used? Can I println my custom debug message to a console window?
I just run the main.go with the command like
go run main.go
and it says

undefined: Asset
undefined: AssetDir
undefined: RestoreAssets
undefined: handleMessages

I know those are provided by bundler but I don't know how to debug the code effectively.
2017년 4월 26일 수요일 오전 4시 54분 22초 UTC+9에 Asticode님이 작성:
Reply all
Reply to author
Forward
0 new messages