Skip to content

Commit

Permalink
Pull request issues resolved
Browse files Browse the repository at this point in the history
* Remove contect from tests
* Resorted package dependacy for TestSearch
* Removed extra notes from README
  • Loading branch information
chrisjoyce911 committed May 27, 2023
1 parent bcbf8ae commit dfdb359
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 27 deletions.
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,6 @@ Also note, that if you call this function too quickly, Google detects that it is
</svg>
</details>

## Using a Fork

If you are wanting to use an active Fork you can replace it in your gomod.go by doing the following

```bash
go get github.com/chrisjoyce911/google-search
go mod edit -replace github.com/rocketlaunchr/google-search=github.com/chrisjoyce911/google-search@master
go mod tidy
```

## Credits

Expand Down
15 changes: 8 additions & 7 deletions example_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package googlesearch

import (
"context"
"fmt"
"strings"
)
Expand All @@ -12,14 +11,15 @@ func ExampleSearch() {
CountryCode: "au",
}

serp, err := Search(context.Background(), "First Aid Course Australia Wide First Aid", opt)
//lint:ignore SA1012 ignore this bare essentials by passing nil for context and removing context package (despite not being idiomatic go).
serp, err := Search(nil, "First Aid Course Australia Wide First Aid", opt)

if err != nil {
fmt.Print(err.Error())
}

for _, resault := range serp {
if strings.Contains(resault.URL, "australiawidefirstaid.com.au") {
for _, result := range serp {
if strings.Contains(result.URL, "australiawidefirstaid.com.au") {
fmt.Println("Australia Wide First Aid (https://www.australiawidefirstaid.com.au/) found in the serp")
break
}
Expand All @@ -42,14 +42,15 @@ func ExampleUserAgent() {
UserAgent: "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36",
}

serp, err := Search(context.Background(), "First Aid Course Australia Wide First Aid", opt)
//lint:ignore SA1012 ignore this bare essentials by passing nil for context and removing context package (despite not being idiomatic go).
serp, err := Search(nil, "First Aid Course Australia Wide First Aid", opt)

if err != nil {
fmt.Print(err.Error())
}

for _, resault := range serp {
if strings.Contains(resault.URL, "australiawidefirstaid.com.au") {
for _, result := range serp {
if strings.Contains(result.URL, "australiawidefirstaid.com.au") {
fmt.Println("Australia Wide First Aid (https://www.australiawidefirstaid.com.au/) found in the serp")
break
}
Expand Down
6 changes: 1 addition & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/rocketlaunchr/google-search

go 1.20
go 1.16

require (
github.com/gocolly/colly/v2 v2.1.0
Expand All @@ -13,14 +13,10 @@ require (
github.com/antchfx/htmlquery v1.3.0 // indirect
github.com/antchfx/xmlquery v1.3.15 // indirect
github.com/antchfx/xpath v1.2.4 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/kennygrant/sanitize v1.2.4 // indirect
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect
github.com/temoto/robotstxt v1.1.2 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/text v0.9.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.30.0 // indirect
)
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
github.com/gocolly/colly v1.2.0 h1:qRz9YAn8FIH0qzgNUw+HT9UN7wm1oF9OBAilwEWpyrI=
github.com/gocolly/colly v1.2.0/go.mod h1:Hof5T3ZswNVsOHYmba1u03W65HDWgpV5HifSuueE0EA=
github.com/gocolly/colly/v2 v2.1.0 h1:k0DuZkDoCsx51bKpRJNEmcxcp+W5N8ziuwGaSDuFoGs=
github.com/gocolly/colly/v2 v2.1.0/go.mod h1:I2MuhsLjQ+Ex+IzK3afNS8/1qP3AedHOusRPcRdC5o0=
Expand Down Expand Up @@ -119,11 +120,13 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
Expand Down
12 changes: 6 additions & 6 deletions search_test.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
// Copyright 2020-21 PJ Engineering and Business Solutions Pty. Ltd. All rights reserved.

package googlesearch
package googlesearch_test

import (
"context"
"testing"
)

var ctx = context.Background()
googlesearch "github.com/rocketlaunchr/google-search"
)

func TestSearch(t *testing.T) {

q := "Hello World"

opts := SearchOptions{
opts := googlesearch.SearchOptions{
Limit: 20,
}

returnLinks, err := Search(ctx, q, opts)
//lint:ignore SA1012 ignore this bare essentials by passing nil for context and removing context package (despite not being idiomatic go).
returnLinks, err := googlesearch.Search(nil, q, opts)
if err != nil {
t.Errorf("something went wrong: %v", err)
return
Expand Down

0 comments on commit dfdb359

Please sign in to comment.