DEV Community

Cover image for Building cross platform desktop applications using JavaScript, HTML, and CSS in GO

Posted on

Building cross platform desktop applications using JavaScript, HTML, and CSS in GO

Energy is the framework for Go to build desktop applications based on CEF



Project Introduction

  • Energy is a framework developed by Golang based on CEF(Chromium Embedded Framework), embedded with CEF binary

  • Use Go and Web technology (HTML+CSS+JavaScript) to build cross-platform desktop applications that support Windows, Linux and MacOS

  • Knowledge of the front-end technology stack and some knowledge of the Go language is required


  • development environment is simple and the compilation speed is fast. Only the Go development environment and the CEF binary framework that Energy depends on are needed
  • cross-platform: A set of code can be packaged into Windows, domestic UOS, Deepin, Kylin, MacOS, Linux
  • Language responsibilities

  • Go: Go is responsible for window creation, CEF configuration and function implementation, creation of various UI components, low-level system calls, and functions that JS cannot handle, such as file stream, security encryption, high-performance processing, etc., which can be developed as a pure backend

  • Web: HTML + CSS + JavaScript responsible for the function of the client interface, make any interface you want, can be used as a pure front-end development

  • front-end technology: Support mainstream front-end frameworks, such as Vue, React, Angular or pure HTML+CSS

  • event driven: High performance event driven, IPC based communication, Go and Web side is very convenient function call and data interaction

Go interacts with the Web

  • The Go and Web technologies are based on IPC communication. Data and event triggering can be exchanged between Go and Web without using the http interface, which is as simple as calling the functions of the language itself

  • Define JS binding type variables in Go and provide them to JS on the Web side to realize data synchronization of Go variables or structural objects

  • Listen for events in JS and trigger JS events in Go to achieve Go calling JS functions and passing parameter

  • Listen for events in Go and trigger Go events in JS to achieve JS calling Go functions and passing parameters

Built-in dependency&integration

  • Golcl
  • CEF

Development environment

  • Install automatically using the energy command line tool

Basic needs

golang >= 1.18

energy development environment

Use the energy command line tool to automatically install the development environment

Get energy project, or use the precompiled command line tool directly Download address

go get
Enter the energy command line directory

cd energy/cmd/energy
Install command line tools

go install
Execute the installation command

energy install .
Enter fullscreen mode Exit fullscreen mode

example/simple Code

package main

import (

func main() {
    //Global initialization must be called by every application
    cef.GlobalInit(nil, nil)
    //Create application
    cefApp := cef.NewApplication()
    //Set URL
    cef.BrowserWindow.Config.Url = ""
    //Run App
Enter fullscreen mode Exit fullscreen mode

System support

  • windows - 32, 64
  • linux, linux-arm - 64
  • mac 64

Exchange QQ Group

  • 541258627


Public License


Top comments (0)