1
0
Fork 0
mirror of https://github.com/Luzifer/nginx-sso.git synced 2024-12-21 05:11:17 +00:00
nginx-sso/vendor/google.golang.org/api/examples/customsearch.go
Knut Ahlers 9b3c895c04
Update dependencies
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2019-04-22 06:44:07 +02:00

39 lines
808 B
Go

// Copyright 2018 Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"fmt"
"log"
"net/http"
customsearch "google.golang.org/api/customsearch/v1"
"google.golang.org/api/googleapi/transport"
)
const (
apiKey = "some-api-key"
cx = "some-custom-search-engine-id"
query = "some-custom-query"
)
func customSearchMain() {
client := &http.Client{Transport: &transport.APIKey{Key: apiKey}}
svc, err := customsearch.New(client)
if err != nil {
log.Fatal(err)
}
resp, err := svc.Cse.Siterestrict.List(query).Cx(cx).Do()
if err != nil {
log.Fatal(err)
}
for i, result := range resp.Items {
fmt.Printf("#%d: %s\n", i+1, result.Title)
fmt.Printf("\t%s\n", result.Snippet)
}
}