/golang-bigtable-sample

Demonstrates using bigtable with golang

Primary LanguageGoApache License 2.0Apache-2.0

CRUD for Hotel

Install Bigtable Emulator

gcloud components install bigtable

Install cbt tool

gcloud components install cbt

Start emulator

gcloud beta emulators bigtable start --host-port=localhost:8086

Create a table and column family

In a different console:

export BIGTABLE_EMULATOR_HOST=localhost:8086
cbt -project "project-id" -instance "bus-instance" createtable hotels
cbt -project "project-id" -instance "bus-instance" createfamily hotels hotel_details

Check if table exists

cbt -project "project-id" -instance "bus-instance" ls
cbt -project "project-id" -instance "bus-instance" read hotels

Populate Data

export BIGTABLE_EMULATOR_HOST=localhost:8086
cd write
go run writeRecords.go

Ensure data shows up in the table

cbt -project "project-id" -instance "bus-instance" ls
cbt -project "project-id" -instance "bus-instance" read hotels

Read Records

export BIGTABLE_EMULATOR_HOST=localhost:8086
cd read
go run readRecords.go -zip or-01