Cloud Bigtable Quickstart in Go
This application demonstrates using the Google Cloud APIs Go
Client Library to connect
to a Cloud Bigtable instance and read a row from a table.
Before you begin
-
Select or create a Cloud Platform project.
-
Enable billing for your project.
-
Enable the Cloud Bigtable API.
Note: The quickstart performs an operation on an existing table (created below).
If you require your code to create instances or tables,
the Admin API
must be enabled as well.
-
Set up authentication with a service account so you can access the API from your local workstation.
-
Follow the instructions in the user documentation to
create a Cloud Bigtable instance (if necessary).
-
Follow the cbt tutorial to install the
cbt
command line tool.
Here are the cbt
commands to create a table, column family and add some data:
cbt createtable my-table
cbt createfamily my-table cf1
cbt set my-table r1 cf1:c1=test-value
Running the quickstart
The quickstart sample shows how to read rows from a table with the Bigtable client library.
Run the quickstart to read the row you just wrote using cbt
:
`go run main.go -project PROJECT_ID -instance INSTANCE_ID -table my-table
Expected output similar to:
2018/06/15 18:50:52 Getting a single row by row key:
2018/06/15 18:50:54 Row key: r1
2018/06/15 18:50:54 Data: test-value
Cleaning up
To avoid incurring extra charges to your Google Cloud Platform account, remove
the resources created for this sample.
-
Go to the Cloud Bigtable instance page in the Cloud Console.
-
Click on the instance name.
-
Click Delete instance.
-
Type the instance ID, then click Delete to delete the instance.