This repository provides go bindings for the bcc framework as well as low-level routines to load and use eBPF programs from .elf files.
gobpf is in early stage, but usable. Input and contributions are very much welcome.
To get started, first install (either by package or source) libbcc. Then, simply:
go install github.com/iovisor/gobpf
sudo -E go test github.com/iovisor/gobpf
Example code can be found in the examples/
directory.
We recommend to vendor gobpf and pin its version as the API probably undergoes change during development.
To build ELF object files for usage with github.com/iovisor/gobpf/elf
, you
must use distinct sections (SEC("...")
). Currently, only kprobe/...
,
maps/...
, cgroup/skb
and cgroup/sock
are supported. For an example, see
tests/dummy.c
.