forked from GoogleCloudPlatform/golang-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (31 loc) · 1002 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2016 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// [START bigquery_quickstart]
// Sample bigquery-quickstart creates a Google BigQuery dataset.
package main
import (
"fmt"
"log"
// Imports the Google Cloud BigQuery client package.
"cloud.google.com/go/bigquery"
"golang.org/x/net/context"
)
func main() {
ctx := context.Background()
// Sets your Google Cloud Platform project ID.
projectID := "YOUR_PROJECT_ID"
// Creates a client.
client, err := bigquery.NewClient(ctx, projectID)
if err != nil {
log.Fatalf("Failed to create client: %v", err)
}
// Sets the name for the new dataset.
datasetName := "my_new_dataset"
// Creates the new BigQuery dataset.
if err := client.Dataset(datasetName).Create(ctx, &bigquery.DatasetMetadata{}); err != nil {
log.Fatalf("Failed to create dataset: %v", err)
}
fmt.Printf("Dataset created\n")
}
// [END bigquery_quickstart]