Go
|
Go (also called Go-lang) is a language developed at Google. It was never designed to be a bare metal language, but with some tricks you can compile a kernel with it.
Operating System Development
Go has a comparable amount of runtime to C and C++, and the language needs some callbacks in order to work. Most notably Go can't convert an integer into a pointer (which is trivial in C and very important in a kernel), you'll have to write a small Assembly wrapper for that. Expect the need for creating wrappers just like that to workaround the language and make suitable for bare metal. Some of the projects below simply use C for the parts which cannot be written in Go natively (Multiboot header being one of them).
Details were discussed at GolangUK2017 talk "Bare Metal Gophers: Can you write a kernel in Go?", see slides here.
At the 36th Chaos Communication Congress in 2019 a full framework for bare metal Go development was released, see talk and slides, the TamaGo framework currently supports several ARM unikernels and also support AMD64 KVM bare metal execution.
Projects
- Bare Metal Gophers - code repository for the talk (does not compile with latest Go compiler)
- TamaGo - a complete bare metal Go for AMD64/ARM/RISC-V processors
- EggOS - a fairly complete environment to run Go applications on bare metal (some parts written in C)
- Goose - the bare minimum environment and a protected mode "Hello World" kernel in Go
- mykernel a simplistic, long mode "Hello World" kernel in Go
See Also
- Go Bare Bones
- BOOTBOOT loader has an example 64 bit higher half kernel in Go