Debian Codegraph @

docs/examples/features_test.go

raw symbols SCIP
1 //go:build linux
2
3 package examples
4
5 import (
6 "errors"
7 "fmt"
8
9 "github.com/cilium/ebpf"
10 "github.com/cilium/ebpf/features"
11 )
12
13 func DocDetectXDP() {
14 err := features.HaveProgramType(ebpf.XDP)
15 if errors.Is(err, ebpf.ErrNotSupported) {
16 fmt.Println("XDP program type is not supported")
17 return
18 }
19 if err != nil {
20 // Feature detection was inconclusive.
21 //
22 // Note: always log and investigate these errors! These can be caused
23 // by a lack of permissions, verifier errors, etc. Unless stated
24 // otherwise, probes are expected to be conclusive. Please file
25 // an issue if this is not the case in your environment.
26 panic(err)
27 }
28
29 fmt.Println("XDP program type is supported")
30 }