TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Golang Desktop App with Webview/Lorca, WASM and Bazel

154 pointsby grahar64almost 5 years ago

18 comments

pjmlpalmost 5 years ago
The workarounds one goes through to avoid native frameworks.<p>&quot;Hands-On GUI Application Development in Go: Build responsive, cross-platform, graphical applications with the Go programming language&quot;<p><a href="https:&#x2F;&#x2F;www.amazon.de&#x2F;-&#x2F;en&#x2F;Andrew-Williams-ebook&#x2F;dp&#x2F;B07GYLYSCT" rel="nofollow">https:&#x2F;&#x2F;www.amazon.de&#x2F;-&#x2F;en&#x2F;Andrew-Williams-ebook&#x2F;dp&#x2F;B07GYLYS...</a>
评论 #24118409 未加载
评论 #24119774 未加载
评论 #24118264 未加载
jchwalmost 5 years ago
I just recently tried webview&#x2F;webview in Go and was a little fed up with the fact that it could not be a single-binary plug &amp; play experience on Windows. To that end, I am working on an experimental alternative that uses Webview2 directly without CGo: <a href="https:&#x2F;&#x2F;github.com&#x2F;jchv&#x2F;go-webview2" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jchv&#x2F;go-webview2</a><p>It still requires WebView2Loader.dll, but I am working on another library so I can just embed it directly into the application, and that work is happening over here: <a href="https:&#x2F;&#x2F;github.com&#x2F;jchv&#x2F;go-winloader" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jchv&#x2F;go-winloader</a><p>Sorry for the blatant self promotion, but I thought fellow stubborn people might have a desire to drop to as few dependencies as possible. I prefer building without CGo. The only downside is there’s not really a great way to fall back to EdgeHTML so users will need a Webview2 install, and right now Windows isn’t shipping it, but I think going forward it will be reasonable to just link users to the webview2 runtime page to go install it.<p>(Also, it should go without saying, but this approach only improves things on Windows. You will still need other bindings for other platforms.)
评论 #24119197 未加载
评论 #24118519 未加载
WinstonSmith84almost 5 years ago
People complains about this setup but WASM is optional. I&#x27;ve been using Golang with Lorca <i>without</i> WASM. I actually don&#x27;t see the value of WASM here.. Anyway, I used Svelte on the frontend, pretty straightforward but any other lib would have been as easy to bind. And it just... works.<p>The main advantage over Electron is the size of the bin (~20MB for a medium app vs. &gt;100MB if it was Electron). If you know the people who are going to use your app have Chrome installed, it&#x27;s definitely better than Electron and you get the best of both worlds - quick crafted &amp; beautiful UI and performant backend
评论 #24121431 未加载
snarfyalmost 5 years ago
My problem with these approaches, is what&#x27;s the next step? Do you implement GUI buttons on top of canvas and push pixels in WASM? Do you try and do something like ImGui and use WebGL? None of these approaches are efficient. If you are making a native app because it would be more efficient, I&#x27;m not sure what the point of this approach is.
评论 #24120318 未加载
评论 #24120349 未加载
评论 #24125367 未加载
Philip-J-Fryalmost 5 years ago
Personally I&#x27;m a big fan of <a href="https:&#x2F;&#x2F;github.com&#x2F;wailsapp&#x2F;wails&#x2F;" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;wailsapp&#x2F;wails&#x2F;</a><p>It uses native webview so no electron. Let&#x27;s you effortlessly bind JS functions to those in Go.<p>V2 is in the works and will effectively bring the best features of electron window management (menus, frameless windows, drag regions etc) over to native webview.<p>Currently uses IE11 on Win 10 but V2 will only support Edge so you get WebKit across the board.
评论 #24119286 未加载
评论 #24118311 未加载
eivarvalmost 5 years ago
In general, why would one take this approach of embedding a browser, compiling to WASM, etc. over a native UI?<p>I&#x27;m genuinely curious why&#x2F;when this is a better solution.
评论 #24118587 未加载
评论 #24118197 未加载
评论 #24119220 未加载
ptrikalmost 5 years ago
Carlo [1] was an exciting project to hear, sad that it&#x27;s no longer maintained. Glad to see Lorca [2] as a spiritual successor.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;GoogleChromeLabs&#x2F;carlo&#x2F;" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;GoogleChromeLabs&#x2F;carlo&#x2F;</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;zserge&#x2F;lorca" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;zserge&#x2F;lorca</a>
steevealmost 5 years ago
Cool article!<p>Small note: you can use rules_go&#x27;s builtin go_embed_data [1] rule instead of rolling out your own using genrule.<p>1. <a href="https:&#x2F;&#x2F;github.com&#x2F;bazelbuild&#x2F;rules_go&#x2F;blob&#x2F;master&#x2F;go&#x2F;extras.rst#go_embed_data" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;bazelbuild&#x2F;rules_go&#x2F;blob&#x2F;master&#x2F;go&#x2F;extras...</a>
评论 #24121026 未加载
_lobsteralmost 5 years ago
I generally recommend Sciter for desktop apps; The programming model is extremely intuitive and straightforward, and in my experience, the performance is excellent. Besides that, I&#x27;d look at something like webview
评论 #24119133 未加载
AnonsLadderalmost 5 years ago
Well done, I too am building a desktop app in Go, I couldn&#x27;t find a decent GUI library and just resorted to packing a webserver &amp; static files into my program instead. For the time being anyway, still looking for Gui options. Figured I could make a creative html&#x2F;css UI instead of figuring out how to create a GUI. I&#x27;d like to mess with Qt but the GUI builder is with their paid licensing iirc i think, but it seems to be the only cross-platform solution afaik
评论 #24118893 未加载
评论 #24118829 未加载
Maxencealmost 5 years ago
Hello,<p>I&#x27;m super happy to see that some folks are trying to make apps with Golang.<p>I&#x27;m myself the author of a Go package to build GUI with WASM and Go =&gt; <a href="https:&#x2F;&#x2F;github.com&#x2F;maxence-charriere&#x2F;go-app" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;maxence-charriere&#x2F;go-app</a><p>WASM give us an incredible amount of new possibilities and hopefully, we will get to a point where Go will be used in production also for GUI&#x2F;apps purposes :)<p>Congrats for this and good luck for the future.
评论 #24127940 未加载
Jolteralmost 5 years ago
Knowing next to nothing about Golang: Is it unlikely that someone would ever develop an actual desktop toolkit for Golang? If so, how come?<p>From a naïve point of view, it would seem like overkill to run a whole web browser when a few kilobytes of memory is all it really takes to draw a widget on screen.
评论 #24118165 未加载
评论 #24118136 未加载
LeoNatan25almost 5 years ago
If one is using Go&#x2F;C++&#x2F;whatever WASM, why not go the extra step and use a binding framework for the OS&#x27;s native UI toolkit, and just produce a native app? I don&#x27;t understand with the fascination of bringing an entire OS (the browser) on top of an OS.
评论 #24120819 未加载
rajveermalviyaalmost 5 years ago
This is great but there many drawbacks. I tried Qt but needed something native-er.<p>After much digging got to know about gioui[1] but it also has some issues. Also Flutter[2] seems to be better fit but binding to golang is a little tough.<p>[1]: <a href="https:&#x2F;&#x2F;gioui.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;gioui.org&#x2F;</a><p>[2]: <a href="https:&#x2F;&#x2F;flutter.dev&#x2F;" rel="nofollow">https:&#x2F;&#x2F;flutter.dev&#x2F;</a>
评论 #24118623 未加载
评论 #24119225 未加载
rwitoffalmost 5 years ago
Does this lead to a significantly smaller memory footprint than otherwise running .js in electron or a full browser?<p>I see you&#x27;ve become a big fan of bazel :)
评论 #24119160 未加载
kgersenalmost 5 years ago
see <a href="https:&#x2F;&#x2F;www.vugu.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.vugu.org&#x2F;</a>
评论 #24121131 未加载
fmakunboundalmost 5 years ago
Err, what you have there is a web app.
zachripalmost 5 years ago
<i>But I don’t want to write JavaScript(!) and deal with all the complexities that comes with it like npm, webpack, typescript… Fortunately, I can just compile GoLang to WebAssembly (WASM)</i><p>Okay...<p><i>Large WASM binaries (especially from GoLang): these take a long time to send over the network increasing loading times. In a desktop app the binary isn’t transferred over the network, so less overhead.</i><p>I forgot that you don&#x27;t have to download desktop apps, they just appear!<p><i>Browser incompatibility: Some WebAssembly methods are unavailable in browsers and older browsers are not supported at all. In a desktop app the “browser” is controlled (Chrome for Lorca and Safari for webview), so no compatibility issues.</i><p>Electron???<p>This just seems like you built a less easy to use bundling&#x2F;development platform than js&#x2F;webpack&#x2F;etc and claimed it was better when I&#x27;d argue it&#x27;s way less mainstream and thus less accessible. Not to mention you could&#x27;ve just used native ui like others are talking about. Seems like the worst of both worlds to me.
评论 #24118609 未加载
评论 #24118806 未加载