Moved example to a test
This commit is contained in:
parent
552a24ed32
commit
e6cefd6ada
@ -1,13 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
googlesearch "github.com/chrisjoyce911/google-search"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
fmt.Println(googlesearch.Search(context.Background(), "First Aid Course Australia Wide First Aid"))
|
||||
}
|
30
example_test.go
Normal file
30
example_test.go
Normal file
@ -0,0 +1,30 @@
|
||||
package googlesearch
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func ExampleSearch() {
|
||||
|
||||
opt := SearchOptions{
|
||||
CountryCode: "au",
|
||||
}
|
||||
|
||||
serp, err := Search(context.Background(), "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") {
|
||||
fmt.Println("Australia Wide First Aid (https://www.australiawidefirstaid.com.au/) found in the serp")
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Output: Australia Wide First Aid (https://www.australiawidefirstaid.com.au/) found in the serp
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user