Show HN: Write your BPF programs in Go, not C
Gobee is a tool that allows users to write BPF programs in Go instead of C. It transpiles a strict subset of Go into BPF C and generates typed Go bindings for userspace. This approach aims to simplify the development process for BPF programs by integrating both kernel and userspace components within a single Go module.
- ▪Gobee transpiles Go code into BPF C, enabling easier BPF program development.
- ▪It generates typed Go bindings for userspace, enhancing usability.
- ▪The tool is designed for cases where both kernel and userspace sides are needed in one Go module.
Opening excerpt (first ~120 words) tap to expand
gobee Write your BPF programs in Go, not C. gobee transpiles a strict subset of Go into BPF C, generates typed Go bindings for the userspace side, and gates loads against the running kernel. The Go ecosystem has solid userspace tooling for BPF. The kernel side has always ended with "now write your program in C." Aya brought eBPF to Rust by writing a new BPF backend in rustc. gobee gets there a different way: by transpiling to C and reusing clang's mature backend. A Go file in, a BPF program out A tracepoint that streams every execve to userspace via a ringbuf: Your input (Go) What gobee emits (BPF C) //go:build ignore package main import "github.com/boratanrikulu/gobee/bpf" //bpf:license GPL type Event struct { Pid uint32 Comm [16]byte } var Events = bpf.RingBuf[Event]{ MaxEntries: 4096,…
Excerpt limited to ~120 words for fair-use compliance. The full article is at GitHub.