r/golang • • 1d ago

Linux kernel modules in Go

https://jespino.github.io/gokm/
202 Upvotes

10 comments sorted by

73

u/jerf 1d ago

Mod note: Normally this would fit well within my "small project" criteria, however I'm going to use a rare executive call here to let this go to the front page, because I think there's also an entire interesting conversation to be had on the utility of this approach, whether it has any use cases, costs/benefits, etc., that is, a general discussion of the utility of Go in a kernel rather than necessarily this project specifically.

10

u/mashmorgan 1d ago

Glad u did.. Am developing some lab.equpment.. and am looking for go without the "runtime" for want of word...

4

u/cookiengineer 19h ago edited 19h ago

Go checkout cilium, that's the standard eBPF framework everyone is using for Linux kernel development.

2

u/gamewiz365 6h ago

This. 

WARN: There's no such thing as a perfectly sandboxed environment (gestures broadly to this past week year). caveat emptor.

With that out of the way, eBPF gives you access to the kernel space without having to write an entire kernel module while providing additional tooling to help the developer help themself like extra verification that your program will remain within its sandboxed environment, helper functions, an entire library of data types for working with storage: bpf maps, and more.

As u/cookieengineer suggested, Cilium's go-ebpf is the icing on the cake, allowing these programs to be written in Go and compiled down to C and subsequently loaded.

7

u/jackielii 1d ago

Worth it.

3

u/Wild_Percentage5148 23h ago

Appreciate the exception, it's definitely a pretty weird and interesting design space to talk about

10

u/m33-m33 1d ago

As en experiment, or homelab IOT it could be fun.

16

u/Existing-Outside1795 20h ago

Nah, straight to prod baby.

1

u/saydostaygo 17h ago

If it works in dev, it will for sure work in prod!

5

u/hidegitsu 10h ago

Prod has more ram, why wouldn't I just do it there?