Created
August 15, 2014 03:20
-
-
Save najeira/280c347ecb6bd9f2e680 to your computer and use it in GitHub Desktop.
Golang BigQuery example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
bigquery "code.google.com/p/google-api-go-client/bigquery/v2" | |
"code.google.com/p/goauth2/oauth/jwt" | |
"encoding/json" | |
"fmt" | |
) | |
func main() { | |
iss := "[email protected]" | |
scope := bigquery.BigqueryScope | |
pem := `-----BEGIN RSA PRIVATE KEY----- | |
... | |
-----END RSA PRIVATE KEY-----` | |
token := jwt.NewToken(iss, scope, []byte(pem)) | |
transport, _ := jwt.NewTransport(token) | |
client := transport.Client() | |
bq, _ := bigquery.New(client) | |
call := bq.Tabledata.List("projectid", "dataset", "table") | |
call.MaxResults(10) | |
list, _ := call.Do() | |
buf, _ := json.Marshal(list) | |
fmt.Println(string(buf)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment