From da80521ed1e6218f6597c3782acdcedcfdba77d4 Mon Sep 17 00:00:00 2001 From: rocketlaunchr-cto Date: Wed, 11 Mar 2020 16:52:07 +1100 Subject: [PATCH] add context cancelation --- search.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/search.go b/search.go index a3201d6..10bb022 100644 --- a/search.go +++ b/search.go @@ -102,6 +102,11 @@ func Search(ctx context.Context, searchTerm string, opts ...SearchOptions) ([]Re sel := e.DOM for i := range sel.Nodes { + if err := ctx.Err(); err != nil { + rErr = err + return + } + item := sel.Eq(i) rDiv := item.Find("div.r")