Skip to content

Commit 0d45cba

Browse files
committed
examples: uncomment custom search example
This was previously blocking a build. This commit just uncommented the code. Fixes: #469 Change-Id: I9a39a5b227be5e28b17a5ebc8f40a436796304e3 Reviewed-on: https://code-review.googlesource.com/c/google-api-go-client/+/55190 Reviewed-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Tyler Bui-Palsulich <tbp@google.com>
1 parent 36d5edc commit 0d45cba

1 file changed

Lines changed: 33 additions & 25 deletions

File tree

examples/customsearch.go

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,36 @@
44

55
package main
66

7-
// TODO(codyoss): uncomment after next generation and fix
8-
// const (
9-
// apiKey = "some-api-key"
10-
// cx = "some-custom-search-engine-id"
11-
// query = "some-custom-query"
12-
// )
13-
//
14-
// func customSearchMain() {
15-
// client := &http.Client{Transport: &transport.APIKey{Key: apiKey}}
16-
//
17-
// svc, err := customsearch.New(client)
18-
// if err != nil {
19-
// log.Fatal(err)
20-
// }
21-
//
22-
// resp, err := svc.Cse.List().Q(query).Cx(cx).Do()
23-
// if err != nil {
24-
// log.Fatal(err)
25-
// }
26-
//
27-
// for i, result := range resp.Items {
28-
// fmt.Printf("#%d: %s\n", i+1, result.Title)
29-
// fmt.Printf("\t%s\n", result.Snippet)
30-
// }
31-
// }
7+
import (
8+
"fmt"
9+
"log"
10+
"net/http"
11+
12+
"google.golang.org/api/customsearch/v1"
13+
"google.golang.org/api/googleapi/transport"
14+
)
15+
16+
const (
17+
apiKey = "some-api-key"
18+
cx = "some-custom-search-engine-id"
19+
query = "some-custom-query"
20+
)
21+
22+
func customSearchMain() {
23+
client := &http.Client{Transport: &transport.APIKey{Key: apiKey}}
24+
25+
svc, err := customsearch.New(client)
26+
if err != nil {
27+
log.Fatal(err)
28+
}
29+
30+
resp, err := svc.Cse.List().Q(query).Cx(cx).Do()
31+
if err != nil {
32+
log.Fatal(err)
33+
}
34+
35+
for i, result := range resp.Items {
36+
fmt.Printf("#%d: %s\n", i+1, result.Title)
37+
fmt.Printf("\t%s\n", result.Snippet)
38+
}
39+
}

0 commit comments

Comments
 (0)