Skip to content

Commit f072424

Browse files
committed
examples: add linux build tag to uretprobe, ringbuf, socket_dist
The two examples call into package unix which is not available on non-Unix platforms. Add build tags so that GOOS=windows go build ./... works without errors. Signed-off-by: Lorenz Bauer <[email protected]>
1 parent c4e7342 commit f072424

File tree

6 files changed

+14
-8
lines changed

6 files changed

+14
-8
lines changed

example_sock_extract_dist_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build linux
2+
13
package ebpf_test
24

35
// This code is derived from https://github.com/cloudflare/cloudflare-blog/tree/master/2018-03-ebpf

examples/ringbuffer/bpf_bpfeb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/ringbuffer/bpf_bpfel.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/ringbuffer/main.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build linux
2+
13
package main
24

35
import (
@@ -9,13 +11,14 @@ import (
911
"os/signal"
1012
"syscall"
1113

14+
"golang.org/x/sys/unix"
15+
1216
"github.com/cilium/ebpf/link"
1317
"github.com/cilium/ebpf/ringbuf"
1418
"github.com/cilium/ebpf/rlimit"
15-
"golang.org/x/sys/unix"
1619
)
1720

18-
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -type event bpf ringbuffer.c -- -I../headers
21+
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -tags linux -type event bpf ringbuffer.c -- -I../headers
1922

2023
func main() {
2124
// Name of the kernel function to trace.

examples/uretprobe/bpf_x86_bpfel.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/uretprobe/main.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// The program will be attached to the 'readline' symbol in the binary '/bin/bash' and print out
33
// the line which 'readline' functions returns to the caller.
44

5-
//go:build amd64
5+
//go:build amd64 && linux
66

77
package main
88

@@ -15,13 +15,14 @@ import (
1515
"os/signal"
1616
"syscall"
1717

18+
"golang.org/x/sys/unix"
19+
1820
"github.com/cilium/ebpf/link"
1921
"github.com/cilium/ebpf/perf"
2022
"github.com/cilium/ebpf/rlimit"
21-
"golang.org/x/sys/unix"
2223
)
2324

24-
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -target amd64 -type event bpf uretprobe.c -- -I../headers
25+
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -target amd64 -tags linux -type event bpf uretprobe.c -- -I../headers
2526

2627
const (
2728
// The path to the ELF binary containing the function to trace.

0 commit comments

Comments
 (0)