A cross-platform Go binding for Chromium Embedded Framework (CEF) providing a webview-compatible API for building desktop applications with web technologies.
- ✅ Cross-Platform: Linux, macOS, Windows support
- ✅ WebView-Compatible API: Drop-in replacement for
webview/webview - ✅ CEF Integration: Full Chromium browser engine
- ✅ JavaScript Bindings: Call Go functions from JavaScript
- ✅ WSL/WSLg Support: Works on Windows Subsystem for Linux
| Platform | Architecture | Status | Notes |
|---|---|---|---|
| Linux | x64 (amd64) | ✅ Working | Tested on Ubuntu/Debian |
| Linux | ARM64 | Build tags implemented | |
| macOS | x64 (amd64) | Build tags implemented, needs testing | |
| macOS | ARM64 (M1/M2) | Build tags implemented, needs testing | |
| Windows | x64 (amd64) | Build tags implemented, needs testing | |
| Windows | ARM64 | Build tags implemented, needs testing |
- Go 1.26 or later
- C compiler (gcc/clang on Linux/macOS, MinGW on Windows)
- For WSL: WSL2 with WSLg support (
xeyesshould work) - For Linux: X11 or Wayland display server
# Clone the repository
git clone https://github.com/xelus/go-webview-cef.git
cd go-webview-cef
# Download CEF binaries (automatically detects platform)
go run scripts/setup_cef.go
# Build the demo
./run.sh build
# Run the demo
./run.sh runpackage main
import (
"github.com/xelus/go-webview-cef/adapter/webview"
)
func main() {
w := webview.New(false)
defer w.Destroy()
w.Bind("add", func(a, b int) int {
return a + b
})
w.SetTitle("My App")
w.SetSize(1024, 768, webview.HintNone)
w.Navigate(`data:text/html,<!DOCTYPE html>
<html>
<body>
<h1>Go + CEF</h1>
<button onclick="test()">Call Go</button>
<script>
async function test() {
const result = await add(5, 3);
alert("5 + 3 = " + result);
}
</script>
</body>
</html>`)
w.Run()
}type WebView interface {
Run()
Terminate()
Destroy()
Window() unsafe.Pointer
SetTitle(title string)
SetSize(width, height int, hint int)
Navigate(url string)
Init(js string)
Eval(js string)
Bind(name string, fn interface{}) error
Unbind(name string) error
}const (
HintNone = 0
HintFixed = 1
HintMin = 2
HintMax = 3
).
├── adapter/webview/ # WebView-compatible API
├── cef/ # Public API wrappers
├── internal/cefbindings/ # Generated binding types (committed)
├── internal/cefruntime/ # Go-owned runtime state/lifecycle/IPC
├── internal/cefshim/ # Minimal cgo/ABI shim + CEF runtime C file
├── runtime/cef_runtime.h # Stable C ABI boundary header
├── scripts/ # Setup + diagnostics + generators
├── example/ # Example apps
├── third_party/cef/ # Downloaded CEF binaries (gitignored)
└── run.sh # Build & run script
# Native build
go build -o build/demo ./cmd/demo
# Using the run script
./run.sh build
./run.sh run
# Cross-compile for other platforms
GOOS=darwin GOARCH=amd64 go build -o build/demo ./cmd/demo
GOOS=windows GOARCH=amd64 go build -o build/demo.exe ./cmd/demo# Download CEF for macOS
go run scripts/setup_cef.go
# Build
go build -o build/demo ./cmd/demo
# Run
./build/demo# Download CEF for Windows
go run scripts/setup_cef.go
# Build (requires MinGW)
go build -o build/demo.exe ./cmd/demo
# Run
.\build\demo.exeThe implementation uses CEF's C API with a Go-first runtime architecture:
internal/cefruntime: Go lifecycle, browser registry, JS bridge dispatch.internal/cefshim: minimal cgo boundary and callback trampolines.internal/cefshim/cef_runtime_impl.c: single active C runtime implementation.
All platforms use .tar.bz2 archives:
- Linux:
cef_binary_*_linux64.tar.bz2 - macOS:
cef_binary_*_macosx64.tar.bz2 - Windows:
cef_binary_*_windows64.tar.bz2
The implementation includes WSL-specific flags for GPU/graphics compatibility:
--no-sandbox
--disable-gpu
--disable-gpu-compositing
--use-gl=swiftshader
--single-process
If you see GPU errors or display issues:
# Check if DISPLAY is set
echo $DISPLAY
# For WSLg, should be something like: :0
# If not set, try:
export DISPLAY=:0
# Run with the script which sets this automatically
./run.sh runIf you get library loading errors:
# Linux/WSL
export LD_LIBRARY_PATH=$PWD/build:$LD_LIBRARY_PATH
# macOS
export DYLD_LIBRARY_PATH=$PWD/build:$DYLD_LIBRARY_PATH
# Windows (PowerShell)
$env:PATH = "$PWD/build;$env:PATH"If CEF binaries are not found:
# Re-download CEF
rm -rf third_party/cef
go run scripts/setup_cef.go┌─────────────────┐
│ App Code │ Your Go application
├─────────────────┤
│ WebView Adapter │ webview.New(), w.Run()
├─────────────────┤
│ cef package │ Public compatibility wrappers
├─────────────────┤
│ Go Runtime Core │ internal/cefruntime
├─────────────────┤
│ ABI Shim (cgo) │ internal/cefshim
├─────────────────┤
│ CEF C API │ cef_initialize(), cef_browser_create()
├─────────────────┤
│ libcef │ Chromium Embedded Framework
└─────────────────┘
- ✅ CEF downloader with auto-platform detection
- ✅ C wrapper with proper initialization flow
- ✅ Go bindings with platform-specific build tags
- ✅ WebView-compatible adapter layer
- ✅ OnContextInitialized callback for browser creation
- ✅ WSL/WSLg compatibility
- ✅ Multi-process model support
- ✅ Cross-platform build system
⚠️ macOS testing needed⚠️ Windows testing needed
Contributions are welcome! Areas that need help:
- macOS Testing: Verify build and runtime on macOS
- Windows Testing: Verify build and runtime on Windows
- Documentation: Improve setup instructions
- Examples: Add more usage examples
Please submit issues and pull requests on GitHub.
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2026 Xelus
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
- Chromium Embedded Framework - The CEF project
- Spotify CEF Builds - Prebuilt CEF binaries
- CEF is Copyright (c) 2008-2023 Marshall A. Greenblatt
- CEF binaries are ~150-300MB per platform
- The implementation uses CEF's C API (not C++) for better compatibility
- Single-process mode is used for simplified deployment (not recommended for production)
- For production use, consider implementing proper multi-process handling
- Window management is platform-specific and may need adjustments for each OS