Hacker News new | past | comments | ask | show | jobs | submit login

Of course that you can; kernels are not magic. Many kernels have been written in languages with far more heavyweight runtime systems than Go. A few examples have been provided in the comments. Here is a toy example in Go: http://gofy.cat-v.org/

You need some bits of assembly, but that's true for C, C++, Rust and whatever else as well.




he´s not saying that its not possible to use go for that.. its just that the compiler puts the go runtime wich is specific for the userland and that in the end of the line will create a bunch of kernel syscalls for whatever systems you are..

to make this happen, it should be possible to, at least change the runtime , or not use a runtime at all.. so the little boot part in assembly could call a go function in kernel mode


Of course you'll need a specific runtime just like for C you can't use the user space libc. There's no difference between C and Go here.

You can create your own runtime as you see fit. In fact, the Go distribution used to ship with such a bare metal runtime. Search the repository history for the tiny runtime. Reviving it again should be easier then porting Go to a new architecture, which is quite easy. Making a stub runtime (equivalent to booting a C kernel with no libc) is not more than half an hour of work.

Go can call assembly and C, and assembly and C can call Go. This is used a lot in the runtime, nothing special about it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: