ランキングに戻る

icexin/eggos

Goeggos.icexin.com

A Go unikernel running on x86 bare metal

gogolangosdevunikernelnetstackwasmkernel
スター成長
スター
2.3k
フォーク
122
週間成長
Issue
21
1.5k2k
2020年10月2022年9月2024年8月2026年7月
成果物Go Modulesgo get github.com/icexin/eggos
README

CI

中文说明

A Go unikernel running on x86 bare metal

Run Go applications on x86 bare metal, written entirely in Go (only a small amount of C and some assembly), support most features of Go (like GC, goroutine) and standard libraries, also come with a network stack that can run most net based libraries.

The entire kernel is a go application running on ring0. There are no processes and process synchronization primitives, only goroutines and channels. There is no elf loader, but there is a Javascript interpreter that can run js script files, and a WASM interpreter will be added to run WASM files later.

Background

Go's runtime provides some basic operating system abstractions. Goroutine corresponds to processes and channel corresponds to inter-process communication. In addition, go has its own virtual memory management, so the idea of running Go programs on bare metal was born.

It turns out that Go has the ability to manipulate hardware resources, thanks to Go's controllable memory layout, the ability to directly translate hardware instructions without a virtual machine, and C-like syntax. These all make it possible for Go to write programs that run on bare metal. However, there are also some challenges. Go piling in many instructions to perform coroutine scheduling and memory GC, which brings some troubles in some places that cannot be reentrant, such as interrupt handling and system calls.

In general, writing kernel in Go is a very interesting experience. On the one hand, it gave me a deep understanding of Go's runtime. On the other hand, it also provided an attempt to write the operating system kernel on bare metal in addition to the C language.

Architecture

Snapshot

js nes gui

Feature list

  • Basic Go features, such as GC, goroutine, channel.
  • A simple console supports basic line editting.
  • Network stack supports tcp/udp.
  • Go style vfs abstraction using afero
  • A nes game emulator using nes
  • A Javascript interpreter using otto
  • VBE based frame buffer.
  • Some simple network apps (httpd, sshd).
  • GUI support by nucular.

Dependencies

  • Go 1.16.x (higher versions may not work)
  • gcc
  • qemu
  • mage

MacOS

$ go get github.com/magefile/mage
$ brew install x86_64-elf-binutils x86_64-elf-gcc x86_64-elf-gdb
$ brew install qemu

Ubuntu

$ go get github.com/magefile/mage
$ sudo apt-get install build-essential qemu

Quickstart

$ mage qemu

Build your own unikernel

eggos has the ability to convert normal go program into an ELF unikernel which can be running on bare metal.

First, get the egg binary, which can be accessed through https://github.com/icexin/eggos/releases, or directly through go install github.com/icexin/eggos/cmd/egg

Run egg build -o kernel.elf in your project directory to get the kernel file, and then run egg run kernel.elf to start the qemu virtual machine to run the kernel.

egg pack -o eggos.iso -k kernel.elf can pack the kernel into an iso file, and then you can use https://github.com/ventoy/Ventoy to run the iso file on a bare metal.

Here are some examples examples

Happy hacking!

Debug

You can directly use the gdb command to debug, or use vscode for graphical debugging.

First you need to install gdb, if you are under macos, execute the following command

brew install x86_64-elf-gdb

Use the extension Native Debug in vscode to support debugging with gdb

First execute the mage qemudebug command to let qemu start the gdb server, and then use the debug function of vscode to start a debug session. The debug configuration file of vscode is built into the project.

Go provides simple support for gdb, see Debugging Go Code with GDB for details

vscode-gdb

Running on bare metal

If you want eggos to run on bare metal, it is recommended to use grub as the bootloader.

The multiboot.elf generated after executing the make command is a kernel image conforming to the multiboot specification, which can be directly recognized by grub and booted on a bare metal. The sample configuration file refer to boot/grub.cfg

Documentation

docs/README.md

Roadmap

  • WASM runner
  • GUI support
  • 3D graphic
  • x86_64 support
  • SMP support
  • Cloud server support (virtio)
  • Raspberry Pi support (arm64 aka aarch64)

Bugs

The program still has a lot of bugs, often loses response or panic. If you are willing to contribute, please submit a PR, thank you!

Special thanks

The birth of my little daughter brought a lot of joy to the family. This project was named after her name Xiao Dandan. My wife and mother also gave me a lot of support and let me work on this project in my spare time. :heart: :heart: :heart:

関連リポジトリ
avelino/awesome-go

A curated list of awesome Go frameworks, libraries and software

GoGo ModulesMIT Licensegolanggolang-library
awesome-go.com
178.8k13.4k
ollama/ollama

Get up and running with Kimi-K2.6, GLM-5.2, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

GoGo ModulesMIT Licensellamallm
ollama.com
176.6k17.1k
golang/go

The Go programming language

GoGo ModulesBSD 3-Clause "New" or "Revised" Licenseprogramming-languagelanguage
go.dev
135.3k19.3k
kubernetes/kubernetes

Production-Grade Container Scheduling and Management

GoGo ModulesApache License 2.0kubernetesgo
kubernetes.io
123.9k43.7k
fatedier/frp

A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.

GoGo ModulesApache License 2.0proxyreverse-proxy
108.2k15.1k
gohugoio/hugo

The world’s fastest framework for building websites.

GoGo ModulesApache License 2.0gohugo
gohugo.io
89k8.3k
gin-gonic/gin

Gin is a high-performance HTTP web framework written in Go. It provides a Martini-like API but with significantly better performance—up to 40 times faster—thanks to httprouter. Gin is designed for building REST APIs, web applications, and microservices.

GoGo ModulesMIT Licenseservermiddleware
gin-gonic.com
88.9k8.7k
syncthing/syncthing

Open Source Continuous File Synchronization

GoGo ModulesMozilla Public License 2.0synchronizationgo
syncthing.net
86.8k5.4k
junegunn/fzf

:cherry_blossom: A command-line fuzzy finder

GoGo ModulesMIT Licensefzfgo
junegunn.github.io/fzf/
81.9k2.8k
grafana/grafana

The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.

TypeScriptnpmGNU Affero General Public License v3.0grafanamonitoring
grafana.com
75.7k14.3k
caddyserver/caddy

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

GoGo ModulesApache License 2.0goweb-server
caddyserver.com
74.2k4.8k
moby/moby

The Moby Project - a collaborative project for the container ecosystem to assemble container-based systems

GoGo ModulesApache License 2.0dockercontainers
mobyproject.org
71.9k19k