GPU based Electron on a diet
Go to file
V-X 13fc875b27
Create LICENSE
2019-10-07 15:40:54 -05:00
examples/create-react-app Example version bump 2019-10-07 19:58:03 -05:00
include Bump to Ultralight 1.1 2019-10-07 14:04:16 -05:00
ultralight Include MacOS binaries 2019-10-07 19:55:16 -05:00
.gitignore init 2019-09-26 15:33:10 -05:00
LICENSE Create LICENSE 2019-10-07 15:40:54 -05:00
README.md Update README.md 2019-10-07 15:19:53 -05:00
go.mod Usability features 2019-10-07 19:29:22 -05:00
logo.svg readme 2019-10-04 18:54:37 -05:00
muon.go callback fix 2019-10-07 19:32:38 -05:00
muon_test.go Arrays and complex objects 2019-10-03 00:01:39 -05:00
ultralight.yml Bump to Ultralight 1.1 2019-10-07 14:04:16 -05:00

README.md

gnet

GitHub code size in bytes


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 embeded 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.

Features

  • Full JS to Go interop
  • GPU based rendering
  • Cross-platform
  • Hot-reloading
  • Superior disk size + memory & cpu usage

Comparison with a "Hello, World!" React App

Muon Electron
CPU 0.0% 1.2%
MEM 26.0 MB 201.7 MB
DISK 42 MB 136 MB

Example

From examples/create-react-app/main.go:

package main

import (
  "github.com/ImVexed/muon"

  "cra-go/webfiles"
  "net/http"
)

func main() {
  // Any static asset packer of your liking (ex. fileb0x)
  fileHandler := http.FileServer(webfiles.HTTP)

  cfg := &muon.Config{
    Title:      "Hello, World!",
    Height:     500,
    Width:      500,
    Tilted:     true,
    Resizeable: true,
  }

  m := muon.New(cfg, fileHandler)

  // Expose our `add` function to the JS runtime
  m.Bind("add", add)

  // Show the Window and start the Runtime
  if err := m.Start(); err != nil {
    panic(err)
  }
}

// Muon automatically handles interop to and from the JS runtime
func add(a float64, b float64) float64 {
  return a + b
}

FAQ

Q: How are JS types translated to Go types?

  • JS: Boolean Go: bool
  • JS: Number Go: float64
  • JS: String Go: string
  • JS: Object Go: struct via JSON

Q: I get exit status 3221225781 when I try to run my program

  • Your program likely can't find the Ultralight libraries. Ensure they're either installed on the system, or, in the same folder as your program. Currently, Muon uses the 1.1 Ultralight pre-release that hasn't yet propogated to their main site and can only be downloaded from the Ultralight github repo.

Q: How do I get rid of the Console window on Windows?

  • Add -ldflags -H=windowsgui to either your go build or go run to get rid of the window.