Go Alone

Go Alone 是将 Go 作为面向设备的操作系统运行的实验。「Go Alone is an experiment into running Go as an appliance-oriented operating system」

Github星跟蹤圖

Go Alone

Go Alone 是将 Go 作为一种面向设备的操作系统运行的简短实验。

我们不会在裸机上运行 Go,也不会在 Go 中编写内核 -- 我们使用 Linux,只是用 Go 应用替换用户空间。 所有的用户空间。

单个 Go 应用程序刚刚成为机器的初始化程序 PID 1。 这里没有什么真正困难的,它只是有效。

其中包含的脚本构建了一个最小内核,旨在在 KVM 中运行。 它们甚至不包括对块设备的支持。 采取 12 要素应用程序!

这是运行它们的方法:

# if you have a local clone of linux.git, put it in ~/src/linux/
# to speed up first run
./do-build-kernel
# build and run the hello world example app
./do-run-hello-word
# build and run the network app and forward port 8000 to it
./do-run-network
# in a browser, open http://localhost:8000/
# when done, type control-A x

假定使用 x86_64 平台和 qemu-system-x86_64 的有效安装。

输出应如下所示:

Unpacking initramfs...
Freeing initrd memory: 580K (ffff880007f5f000 - ffff880007ff0000)
io scheduler noop registered (default)
ACPI: PCI Interrupt Link [LNKC] enabled at IRQ 11
Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
00:05: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
Freeing unused kernel memory: 648K (ffffffff81279000 - ffffffff8131b000)
Hello, world! I have 4 CPUs
ACPI: Preparing to enter system sleep state S5
reboot: Power down

路线图

  • 发挥网络配置的作用
  • 也许建立 virtfs
  • 可能在 initramfs 中捆绑资产文件和/或配置
  • 从临时脚本迁移到实用程序命令,并具有可配置性,例如 RAM 大小。悬而未决的问题:
    • 如何处理所需的生成文件?
    • 存放在哪里?
    • 不可见地缓存,或者将其作为 UI 的一部分?
    • 内核可以在许多应用程序之间共享,initramfs 是每个应用程序(版本)
  • 快速 cli 想法
    # build kernel</span>
    alone build-kernel [--version=VER] [--mirror=PATH] OUT_PATH
    # create initramfs
    alone take INITRAMFS_PATH_TO_CREATE GO_PACKAGE
    # run the previously-created kernel and initramfs
    alone exec [--ram=512M] KERNEL INITRAMFS
    # sort of like `go run`, but takes package. builds kernel if needed
    alone run [--kernel-version=VER] [--ram=512M] GO_PACKAGE        


(The first version translated by vz on 2020.08.01)

主要指標

概覽
名稱與所有者tv42/alone
主編程語言Go
編程語言Shell (語言數: 2)
平台Linux
許可證MIT License
所有者活动
創建於2013-12-07 01:14:49
推送於2015-11-12 02:17:07
最后一次提交2015-11-09 18:55:03
發布數0
用户参与
星數76
關注者數4
派生數7
提交數10
已啟用問題?
問題數2
打開的問題數0
拉請求數0
打開的拉請求數1
關閉的拉請求數0
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?

Go Alone

Go Alone is a brief experiment into running Go as an
appliance-oriented operating system.

We do not run Go on bare metal, nor did we write a kernel in Go --
we use Linux, and just replace userspace with a Go app. All of the
userspace.

The single Go application just becames the init, PID 1, of the
machine. There is nothing really difficult here, it just works.

The scripts included build a minimal kernel, intended to run inside a
KVM. They don't even include support for block devices. Take that,
12-factor apps!

Here's how to run them:

# if you have a local clone of linux.git, put it in ~/src/linux/
# to speed up first run
./do-build-kernel

# build and run the hello world example app
./do-run-hello-word

# build and run the network app and forward port 8000 to it
./do-run-network
# in a browser, open http://localhost:8000/
# when done, type control-A x

This assumes x86_64 platform and a working install of
qemu-system-x86_64.

The output should look like this:

...
Unpacking initramfs...
Freeing initrd memory: 580K (ffff880007f5f000 - ffff880007ff0000)
io scheduler noop registered (default)
ACPI: PCI Interrupt Link [LNKC] enabled at IRQ 11
Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
00:05: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
Freeing unused kernel memory: 648K (ffffffff81279000 - ffffffff8131b000)
Hello, world! I have 4 CPUs
ACPI: Preparing to enter system sleep state S5
reboot: Power down

Roadmap

  • play more with network configuration

  • maybe set up virtfs

  • maybe bundle asset files and/or config in the initramfs

  • migrate from ad hoc scripts to utility commands, with
    configurability such as RAM size.. open questions:

    • what to do with generated files that are needed?
    • where to store them?
    • cache invisibly or make that part of the UI?
    • kernel can be shared between many apps, initramfs is per app (version)
  • quick cli ideas

    # build kernel
    alone build-kernel [--version=VER] [--mirror=PATH] OUT_PATH
    
    # create initramfs
    alone take INITRAMFS_PATH_TO_CREATE GO_PACKAGE
    
    # run the previously-created kernel and initramfs
    alone exec [--ram=512M] KERNEL INITRAMFS
    
    # sort of like `go run`, but takes package. builds kernel if needed
    alone run [--kernel-version=VER] [--ram=512M] GO_PACKAGE