The Central Go Modules Repository

To use GoCenter:
export GOPROXY=https://gocenter.io
2,133
Stars
Apache-2.0
License
134,561
Downloads
May 24th 2020
Last Modified
Version:
Loading...

BigQuery GoDoc

Example Usage

First create a bigquery.Client to use throughout your application:

c, err := bigquery.NewClient(ctx, "my-project-ID")
if err != nil {
	// TODO: Handle error.
}

Then use that client to interact with the API:

// Construct a query.
q := c.Query(`
    SELECT year, SUM(number)
    FROM [bigquery-public-data:usa_names.usa_1910_2013]
    WHERE name = "William"
    GROUP BY year
    ORDER BY year
`)
// Execute the query.
it, err := q.Read(ctx)
if err != nil {
	// TODO: Handle error.
}
// Iterate through the results.
for {
	var values []bigquery.Value
	err := it.Next(&values)
	if err == iterator.Done {
		break
	}
	if err != nil {
		// TODO: Handle error.
	}
	fmt.Println(values)
}