does anyone have an example of a Go kernel module

506 views
Skip to first unread message

Siglo XIX

unread,
Jan 6, 2024, 4:22:10 PM1/6/24
to golang-nuts
I have tried many ways but now that the ecosystem is more mature maybe someone knows of an example of how to make a Linux kernle module with Go,.

Hữu Hà

unread,
Jan 7, 2024, 9:06:35 PM1/7/24
to golang-nuts
Maybe you mean something like this ?


Vào lúc 04:22:10 UTC+7 ngày Chủ Nhật, 7 tháng 1, 2024, Siglo XIX đã viết:

Robert Engels

unread,
Jan 7, 2024, 9:20:00 PM1/7/24
to Hữu Hà, golang-nuts
Hasn’t been touched in 6 years and it doesn’t work. I guess they figured out it wasn’t worth the effort. 

The only plausible way to write a kernel module in Go is… don’t.

Maybe run a user space Go process and some sort of shared memory communication. 

On Jan 7, 2024, at 8:06 PM, Hữu Hà <lechu...@gmail.com> wrote:


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/cf1a03df-6782-4ef7-92af-4d3f3dc833c8n%40googlegroups.com.

Amnon

unread,
Jan 14, 2024, 3:38:24 PM1/14/24
to golang-nuts
Why would you want to do that? The amount of stuff going on under the hood in a Go program (GC, scheduling, etc)
make it a bad fit for low level kernel stuff. 

So best stick to C.
Writing a Kernel module in C is well supported and documented.
Having a skim through https://lwn.net/Kernel/LDD3/ .

Recently some people have been writing modules in Rust.
I have not tried it myself, but there is some documentation on the web, eg 
https://www.kernel.org/doc/html/latest/rust/quick-start.html

Or as others have suggested write your program as a plain old user-mode program in Go,
and write a minimal device driver which creates a sys-fs device tree that your program can talk to.
Reply all
Reply to author
Forward
0 new messages