Pull request issues resolved

* Remove contect from tests
* Resorted package dependacy for TestSearch
* Removed extra notes from README
This commit is contained in:
Chris Joyce
2023-05-27 17:31:50 +10:00
parent bcbf8ae1b3
commit dfdb3593e1
5 changed files with 18 additions and 27 deletions

View File

@@ -1,7 +1,6 @@
package googlesearch
import (
"context"
"fmt"
"strings"
)
@@ -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
}
@@ -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
}