Skip to content

Commit

Permalink
Update example to use new func RegisterWithErrorFunc
Browse files Browse the repository at this point in the history
Signed-off-by: giuliano <[email protected]>
  • Loading branch information
giulianopz committed Dec 29, 2023
1 parent f2bdeb0 commit fee052f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions example_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build linux
//go:build linux
// +build linux

package nfqueue_test

Expand All @@ -10,7 +11,7 @@ import (
nfqueue "github.com/florianl/go-nfqueue"
)

func ExampleNfqueue_Register() {
func ExampleNfqueue_RegisterWithErrorFunc() {
// Send outgoing pings to nfqueue queue 100
// # sudo iptables -I OUTPUT -p icmp -j NFQUEUE --queue-num 100

Expand Down Expand Up @@ -42,11 +43,13 @@ func ExampleNfqueue_Register() {
}

// Register your function to listen on nflqueue queue 100
err = nf.Register(ctx, fn)
if err != nil {
fmt.Println(err)
return
}
err = nf.RegisterWithErrorFunc(ctx, fn, func(e error) int {
if err != nil {
fmt.Println(err)
return -1
}
return 0
})

// Block till the context expires
<-ctx.Done()
Expand Down

0 comments on commit fee052f

Please sign in to comment.