From fee052fbf85e5b05a0d3006cb2cbf5d17b3308cd Mon Sep 17 00:00:00 2001 From: giuliano Date: Thu, 28 Dec 2023 19:13:11 +0100 Subject: [PATCH] Update example to use new func RegisterWithErrorFunc Signed-off-by: giuliano --- example_test.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/example_test.go b/example_test.go index d28d938..e452f0a 100644 --- a/example_test.go +++ b/example_test.go @@ -1,4 +1,5 @@ -//+build linux +//go:build linux +// +build linux package nfqueue_test @@ -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 @@ -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()