Example: Go App Engine Application
This example is an App Engine application, written in Go, that
provides a web interface that uses Bigtable to track the number of
visits from your Google account. It runs locally in a Docker container or in the
cloud in App Engine's flexible environment. The code for
this application is in the GitHub repository
GoogleCloudPlatform/golang-samples, in the directory
bigtable/usercounter
.
Overview of the code sample
When the code sample is launched, it creates an administrative client for
Bigtable. It then uses the client to check the user-specified
Bigtable instance for a table named user-visit-counter
, with a
single column family named emails
. If necessary, it creates the table and
column family:
The code sample then creates a single Bigtable client that is used for all subsequent reads and writes:
Finally, the code sample adds an HTTP handler to the root of the App Engine
server. On each request, the handler prompts the user to log in if necessary. It
then tracks the user's visit by performing an Increment
operation on the row
for the user's email address:
After incrementing the row, the handler displays an HTML page showing the total number of visits by the current user.