Scripts2026年7月28日·1 分钟阅读

Lorca — Build HTML5 Desktop Apps in Go Using Chrome

A tiny Go library that creates lightweight desktop applications by using an installed Chrome or Chromium browser as the UI layer, enabling Go backends with web-based frontends in under 1 MB of library code.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Lorca
直接安装命令
npx -y tokrepo@latest install 48826a08-8a61-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

Lorca is a minimalist Go library that turns any HTML5 page into a desktop application by launching Chrome or Chromium in app mode and communicating with it via the Chrome DevTools Protocol. It requires no bundled browser engine, keeping your application tiny while still delivering a modern web UI.

What Lorca Does

  • Opens a Chrome window in app mode without the address bar, tabs, or browser UI
  • Communicates between Go and the browser through the Chrome DevTools Protocol
  • Lets Go code call JavaScript functions and receive return values
  • Lets JavaScript call Go functions that have been explicitly bound
  • Supports loading local HTML files or remote URLs as the application interface

Architecture Overview

Lorca starts Chrome as a subprocess with the --app flag and connects to its remote debugging port via WebSocket. All communication flows through the Chrome DevTools Protocol: Go sends JavaScript evaluation commands, and Chrome returns results as JSON. There is no embedded browser — Lorca relies on an already-installed Chrome or Chromium binary, which keeps the library dependency to a few hundred lines of Go code.

Self-Hosting & Configuration

  • Add Lorca to your Go project with go get github.com/zserge/lorca
  • Chrome or Chromium must be installed on the target machine
  • Set window dimensions and position via the New() constructor parameters
  • Bundle HTML, CSS, and JS assets into the Go binary using embed or a packing tool
  • Cross-compile the Go binary for Windows, macOS, and Linux as usual

Key Features

  • Entire library is under 1000 lines of Go with zero CGo dependencies
  • Bidirectional Go-to-JavaScript function binding for seamless interop
  • Window management including resize, fullscreen, and close detection
  • Evaluate arbitrary JavaScript expressions and retrieve typed results
  • No external build tools or bundlers required beyond the Go toolchain

Comparison with Similar Tools

  • Electron bundles its own Chromium and Node.js, resulting in 150 MB+ apps; Lorca reuses the system Chrome
  • Tauri pairs Rust with the system webview; Lorca pairs Go with the system Chrome
  • Wails is a more full-featured Go desktop framework with build tooling and native bindings
  • go-app compiles Go to WebAssembly for progressive web apps; Lorca runs native Go on the backend
  • Carlo by Google followed a similar Chrome DevTools Protocol approach in Node.js but is now archived

FAQ

Q: What happens if Chrome is not installed? A: Lorca will return an error at startup. You can detect this and prompt the user to install Chrome or Chromium.

Q: Can I distribute the app without requiring Chrome? A: You would need to bundle a Chromium binary alongside your executable, which increases the distribution size significantly.

Q: Is Lorca suitable for production applications? A: Lorca works well for internal tools, utilities, and lightweight desktop apps. For complex production apps, consider Wails or Tauri which offer more features.

Q: Does Lorca support multiple windows? A: Each lorca.New() call creates an independent window. You can manage multiple windows from a single Go process.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产