samples

package module
v0.0.0-...-71aea42 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2018 License: Apache-2.0 Imports: 0 Imported by: 0

README

Google Cloud Platform Go Samples

Kokoro Build Status

This repository holds sample code written in Go that demonstrates the Google Cloud Platform.

Some samples have accompanying guides on cloud.google.com. See respective README files for details.

Contributing changes.

Entirely new samples are not accepted. Bug fixes are welcome, either as pull requests or as GitHub issues.

See CONTRIBUTING.md for details on how to contribute.

Licensing

Code in this repository is licensed under the Apache 2.0. See LICENSE.

Index

Note: samples under docs/appengine are not shown because they mostly do not run, they are just code snippets.

Getting Started
Path Description
getting-started/bookshelf Package bookshelf contains the bookshelf database and app configuration, shared by the main app module and the worker module.
getting-started/bookshelf/app Sample bookshelf is a fully-featured app demonstrating several Google Cloud APIs, including Datastore, Cloud SQL, Cloud Storage.
getting-started/bookshelf/pubsub_worker Sample pubsub_worker demonstrates the use of the Cloud Pub/Sub API to communicate between two modules.
getting-started/helloworld Sample helloworld is a basic App Engine flexible app.
Logging and Monitoring (Stackdriver)
Path Description
docs/error-reporting/fluent Sample fluent demonstrates integration of fluent and Cloud Error reporting.
docs/sql/listinstances Sample listinstances lists the Cloud SQL instances for a given project ID.
docs/storage/listbuckets Command listbuckets lists the Google Cloud buckets for a given project ID.
logging/simplelog Sample simplelog writes some entries, lists them, then deletes the log.
monitoring/custommetric Command custommetric creates a custom metric and writes TimeSeries value to it.
monitoring/listresources Command listresources lists the Google Cloud Monitoring v3 Environment against an authenticated user.
Compute
Path Description
appengine/bigquery This App Engine application uses its default service account to list all the BigQuery datasets accessible via the BigQuery REST API.
appengine_flexible/analytics Sample analytics demonstrates Google Analytics calls from App Engine flexible environment.
appengine_flexible/cloudsql Sample cloudsql demonstrates usage of Cloud SQL for MySQL from App Engine flexible environment.
appengine_flexible/cloudsql_postgres Sample cloudsql_postgres demonstrates usage of Cloud SQL for PostgreSQL from App Engine flexible environment.
appengine_flexible/datastore Sample datastore demonstrates use of the cloud.google.com/go/datastore package from App Engine flexible.
appengine_flexible/endpoints Sample endpoints demonstrates a Cloud Endpoints API.
appengine_flexible/endpoints/client Command client performs authenticated requests against an Endpoints API server.
appengine_flexible/helloworld Sample helloworld is a basic App Engine flexible app.
appengine_flexible/mailgun Sample mailgun is a demonstration on sending an e-mail from App Engine flexible environment.
appengine_flexible/mailjet Sample mailjet is a demonstration on sending an e-mail from App Engine flexible environment.
appengine_flexible/memcache Sample memcache demonstrates use of a memcached client from App Engine flexible environment.
appengine_flexible/pubsub Sample pubsub demonstrates use of the cloud.google.com/go/pubsub package from App Engine flexible environment.
appengine_flexible/sendgrid Sample sendgrid is a demonstration on sending an e-mail from App Engine flexible environment.
appengine_flexible/static_files Package static demonstrates a static file handler for App Engine flexible environment.
appengine_flexible/storage Sample storage demonstrates use of the cloud.google.com/go/storage package from App Engine flexible environment.
appengine_flexible/tiny Sample tiny demonstrates overall program structure: a main package with a main function that calls appengine.Main.
appengine_flexible/twilio Sample twilio demonstrates sending and receiving SMS, receiving calls via Twilio from App Engine flexible environment.
Storage
Path Description
datastore/tasks A simple command-line task list manager to demonstrate using the cloud.google.com/go/datastore package.
storage/buckets Sample buckets creates a bucket, lists buckets and deletes a bucket using the Google Storage API.
Big Data
Path Description
bigquery/syncquery Command syncquery queries a Google BigQuery dataset.
pubsub/subscriptions Command subscriptions is a tool to manage Google Cloud Pub/Sub subscriptions by using the Pub/Sub API.
pubsub/topics Command topics is a tool to manage Google Cloud Pub/Sub topics by using the Pub/Sub API.
Machine Learning
Path Description
language/analyze Command analyze performs sentiment, entity, and syntax analysis on a string of text via the Cloud Natural Language API.
speech/caption Command caption reads an audio file and outputs the transcript for it.
speech/captionasync Command captionasync reads an audio file and outputs the transcript for it.
speech/livecaption Command livecaption pipes the stdin audio data to Google Speech API and outputs the transcript.
speech/wordoffset Command wordoffset sends audio data to the Google Speech API and prints word offset information.
vision/detect Command detect uses the Vision API's capabilities to detect several types of content (label, text, location, etc) for the given image.
vision/label Command label uses the Vision API's label detection capabilities to find a label based on an image's content.
Privacy
Path Description
dlp Samples for the Data Loss Prevention API.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
appengine
bigquery
This App Engine application uses its default service account to list all the BigQuery datasets accessible via the BigQuery REST API.
This App Engine application uses its default service account to list all the BigQuery datasets accessible via the BigQuery REST API.
appengine_flexible
analytics
Sample analytics demonstrates Google Analytics calls from App Engine flexible environment.
Sample analytics demonstrates Google Analytics calls from App Engine flexible environment.
cloudsql
Sample cloudsql demonstrates usage of Cloud SQL from App Engine flexible environment.
Sample cloudsql demonstrates usage of Cloud SQL from App Engine flexible environment.
cloudsql_postgres
Sample cloudsql demonstrates usage of Cloud SQL from App Engine flexible environment.
Sample cloudsql demonstrates usage of Cloud SQL from App Engine flexible environment.
datastore
Sample datastore demonstrates use of the cloud.google.com/go/datastore package from App Engine flexible.
Sample datastore demonstrates use of the cloud.google.com/go/datastore package from App Engine flexible.
endpoints
Sample endpoints demonstrates a Cloud Endpoints API.
Sample endpoints demonstrates a Cloud Endpoints API.
endpoints/client
Command client performs authenticated requests against an Endpoints API server.
Command client performs authenticated requests against an Endpoints API server.
helloworld
Sample helloworld is a basic App Engine flexible app.
Sample helloworld is a basic App Engine flexible app.
mailgun
Sample mailgun is a demonstration on sending an e-mail from App Engine flexible environment.
Sample mailgun is a demonstration on sending an e-mail from App Engine flexible environment.
mailjet
Sample mailjet is a demonstration on sending an e-mail from App Engine flexible environment.
Sample mailjet is a demonstration on sending an e-mail from App Engine flexible environment.
memcache
Sample memcache demonstrates use of a memcached client from App Engine flexible environment.
Sample memcache demonstrates use of a memcached client from App Engine flexible environment.
pubsub
Sample pubsub demonstrates use of the cloud.google.com/go/pubsub package from App Engine flexible environment.
Sample pubsub demonstrates use of the cloud.google.com/go/pubsub package from App Engine flexible environment.
redis
Sample redis demonstrates use of a redis client from App Engine flexible environment.
Sample redis demonstrates use of a redis client from App Engine flexible environment.
sendgrid
Sample sendgrid is a demonstration on sending an e-mail from App Engine flexible environment.
Sample sendgrid is a demonstration on sending an e-mail from App Engine flexible environment.
static_files
Package static demonstrates a static file handler for App Engine flexible environment.
Package static demonstrates a static file handler for App Engine flexible environment.
storage
Sample storage demonstrates use of the cloud.google.com/go/storage package from App Engine flexible environment.
Sample storage demonstrates use of the cloud.google.com/go/storage package from App Engine flexible environment.
tiny
Sample tiny demonstrates overall program structure: a main package with a main function that calls appengine.Main.
Sample tiny demonstrates overall program structure: a main package with a main function that calls appengine.Main.
twilio
Sample twilio demonstrates sending and receiving SMS, receiving calls via Twilio from App Engine flexible environment.
Sample twilio demonstrates sending and receiving SMS, receiving calls via Twilio from App Engine flexible environment.
Package authsnippets contains Google Cloud authentication snippets.
Package authsnippets contains Google Cloud authentication snippets.
bigquery
bigquery_datatransfer_quickstart
Sample bigquery-quickstart creates a Google BigQuery dataset.
Sample bigquery-quickstart creates a Google BigQuery dataset.
bigquery_quickstart
[START bigquery_quickstart] Sample bigquery-quickstart creates a Google BigQuery dataset.
[START bigquery_quickstart] Sample bigquery-quickstart creates a Google BigQuery dataset.
simpleapp
Command simpleapp queries the Stack Overflow public dataset in Google BigQuery.
Command simpleapp queries the Stack Overflow public dataset in Google BigQuery.
snippets
Package snippets contains snippets for the Google BigQuery Go package.
Package snippets contains snippets for the Google BigQuery Go package.
syncquery
Command syncquery queries a Google BigQuery dataset.
Command syncquery queries a Google BigQuery dataset.
bigtable
helloworld
Hello world is a sample program demonstrating use of the Bigtable client library to perform basic CRUD operations
Hello world is a sample program demonstrating use of the Bigtable client library to perform basic CRUD operations
search
Search is a sample web server that uses Cloud Bigtable as the storage layer for a simple document-storage and full-text-search service.
Search is a sample web server that uses Cloud Bigtable as the storage layer for a simple document-storage and full-text-search service.
usercounter
User counter is a program that tracks how often a user has visited the index page.
User counter is a program that tracks how often a user has visited the index page.
cdn
signedurls
Command signedurls creates a signed URL for a Cloud CDN endpoint with the given key.
Command signedurls creates a signed URL for a Cloud CDN endpoint with the given key.
container
listclusters
Command listclusters lists all clusters and their node pools for a given project and zone.
Command listclusters lists all clusters and their node pools for a given project and zone.
datastore
datastore_quickstart
[START datastore_quickstart] Sample datastore-quickstart fetches an entity from Google Cloud Datastore.
[START datastore_quickstart] Sample datastore-quickstart fetches an entity from Google Cloud Datastore.
tasks
A simple command-line task list manager to demonstrate using the cloud.google.com/go/datastore package.
A simple command-line task list manager to demonstrate using the cloud.google.com/go/datastore package.
dialogflow
dlp
dlp_quickstart
dlp_quickstart is a basic example of using the Data Loss Prevention API.
dlp_quickstart is a basic example of using the Data Loss Prevention API.
dlp_snippets
dlp is an example of using the DLP API.
dlp is an example of using the DLP API.
docs
appengine/blobstore
[START complete_sample_application]
[START complete_sample_application]
appengine/cloudsql
Sample cloudsql demonstrates connection to a Cloud SQL instance from App Engine standard.
Sample cloudsql demonstrates connection to a Cloud SQL instance from App Engine standard.
appengine/datastore/transactions
[START using_transactions]
[START using_transactions]
appengine/firebase/tictactoe
Sample tictactoe implements a tic-tac-toe game using Firebase as a communication mechanism.
Sample tictactoe implements a tic-tac-toe game using Firebase as a communication mechanism.
appengine/logs
[START sample_code] This sample gets the app displays 5 log Records at a time, including all AppLogs, with a Next link to let the user page through the results using the Record's Offset property.
[START sample_code] This sample gets the app displays 5 log Records at a time, including all AppLogs, with a Next link to let the user page through the results using the Record's Offset property.
appengine/mail/mailjet
Sample mailjet is a demonstration on sending an e-mail from App Engine standard environment.
Sample mailjet is a demonstration on sending an e-mail from App Engine standard environment.
appengine/requests
[START requests_and_HTTP] [START logging]
[START requests_and_HTTP] [START logging]
appengine/storage
Package gcsdemo is an example App Engine app using the Google Cloud Storage API.
Package gcsdemo is an example App Engine app using the Google Cloud Storage API.
appengine/taskqueue/push
[START intro]
[START intro]
appengine/tools/unittest
[START package_example_1]
[START package_example_1]
appengine/warmup
Sample warmup demonstrates usage of the /_ah/warmup handler.
Sample warmup demonstrates usage of the /_ah/warmup handler.
appengine/xmpp
[START example_sending] [START example_handler]
[START example_sending] [START example_handler]
error-reporting/fluent
Sample fluent demonstrates integration of fluent and Cloud Error reporting.
Sample fluent demonstrates integration of fluent and Cloud Error reporting.
sql/listinstances
Sample listinstances lists the Cloud SQL instances for a given project ID.
Sample listinstances lists the Cloud SQL instances for a given project ID.
endpoints
getting-started
Sample endpoints demonstrates a Cloud Endpoints API.
Sample endpoints demonstrates a Cloud Endpoints API.
getting-started-grpc/helloworld
Package helloworld is a generated protocol buffer package.
Package helloworld is a generated protocol buffer package.
getting-started/client
Command client performs authenticated requests against an Endpoints API server.
Command client performs authenticated requests against an Endpoints API server.
errorreporting
errorreporting_quickstart
Sample errorreporting_quickstart contains is a quickstart example for the Google Cloud Error Reporting API.
Sample errorreporting_quickstart contains is a quickstart example for the Google Cloud Error Reporting API.
firestore
firestore_quickstart
Sample firestore_quickstart demonstrates how to connect to Firestore, and add and list documents.
Sample firestore_quickstart demonstrates how to connect to Firestore, and add and list documents.
firestore_snippets
Command firestore_snippets contains runnable snippet code for Cloud Spanner.
Command firestore_snippets contains runnable snippet code for Cloud Spanner.
getting-started
bookshelf
Package bookshelf contains the bookshelf database and app configuration, shared by the main app module and the worker module.
Package bookshelf contains the bookshelf database and app configuration, shared by the main app module and the worker module.
bookshelf/app
Sample bookshelf is a fully-featured app demonstrating several Google Cloud APIs, including Datastore, Cloud SQL, Cloud Storage.
Sample bookshelf is a fully-featured app demonstrating several Google Cloud APIs, including Datastore, Cloud SQL, Cloud Storage.
bookshelf/pubsub_worker
Sample pubsub_worker demonstrates the use of the Cloud Pub/Sub API to communicate between two modules.
Sample pubsub_worker demonstrates the use of the Cloud Pub/Sub API to communicate between two modules.
helloworld
Sample helloworld is a basic App Engine flexible app.
Sample helloworld is a basic App Engine flexible app.
internal
aeintegrate
Package aeintegrate facilitates end-to-end testing against the production Google App Engine.
Package aeintegrate facilitates end-to-end testing against the production Google App Engine.
cleanaeversions
Command cleaneversions deletes App Engine versions for a given project, service and/or version ID filter.
Command cleaneversions deletes App Engine versions for a given project, service and/or version ID filter.
e2e
testutil
Package testutil provides test helpers for the golang-samples repo.
Package testutil provides test helpers for the golang-samples repo.
webtest
Package webtest provides helpers for testing web applications.
Package webtest provides helpers for testing web applications.
iot
manager
Command manager lets you manage Cloud IoT Core devices and registries.
Command manager lets you manage Cloud IoT Core devices and registries.
iotkit
helloworld
Program helloworld is a tiny program that blinks "Hello gopher!" on a Grove LCD RGB Backlight display connected to a BeagleBone.
Program helloworld is a tiny program that blinks "Hello gopher!" on a Grove LCD RGB Backlight display connected to a BeagleBone.
helloworld/display
Package display is a driver for Grove LCD RGB backlight display.
Package display is a driver for Grove LCD RGB backlight display.
kms
crypter
Command crypter encrypts and decrypts a file.
Command crypter encrypts and decrypts a file.
quickstart
Sample quickstart is a basic program that uses Cloud KMS.
Sample quickstart is a basic program that uses Cloud KMS.
language
analyze
Command analyze performs sentiment, entity, entity sentiment, and syntax analysis on a string of text via the Cloud Natural Language API.
Command analyze performs sentiment, entity, entity sentiment, and syntax analysis on a string of text via the Cloud Natural Language API.
language_quickstart
[START language_quickstart] Sample language-quickstart uses the Google Cloud Natural API to analyze the sentiment of "Hello, world!".
[START language_quickstart] Sample language-quickstart uses the Google Cloud Natural API to analyze the sentiment of "Hello, world!".
logging
exportlogs
Sample exportlogs lists, creates, updates, and deletes log sinks.
Sample exportlogs lists, creates, updates, and deletes log sinks.
logging_quickstart
[START logging_quickstart] Sample logging-quickstart writes a log entry to Stackdriver Logging.
[START logging_quickstart] Sample logging-quickstart writes a log entry to Stackdriver Logging.
simplelog
Sample simplelog writes some entries, lists them, then deletes the log.
Sample simplelog writes some entries, lists them, then deletes the log.
stdlogging
Sample stdlogging writes log.Logger logs to the Stackdriver Logging.
Sample stdlogging writes log.Logger logs to the Stackdriver Logging.
memorystore
redis
Command redis is a basic app that connects to a managed Redis instance.
Command redis is a basic app that connects to a managed Redis instance.
monitoring
alert
The alert sample demonstrates interacting with the monitoring and alerting API.
The alert sample demonstrates interacting with the monitoring and alerting API.
custommetric
Command custommetric creates a custom metric and writes TimeSeries value to it.
Command custommetric creates a custom metric and writes TimeSeries value to it.
listresources
Command listresources lists the Google Cloud Monitoring v3 Environment against an authenticated user.
Command listresources lists the Google Cloud Monitoring v3 Environment against an authenticated user.
monitoring_quickstart
[START monitoring_quickstart] Sample monitoring-quickstart writes a data point to Stackdriver Monitoring.
[START monitoring_quickstart] Sample monitoring-quickstart writes a data point to Stackdriver Monitoring.
opencensus
opencensus_spanner_quickstart
Sample opencensus_spanner_quickstart contains a sample application that uses Google Spanner Go client, and reports metrics and traces for the outgoing requests.
Sample opencensus_spanner_quickstart contains a sample application that uses Google Spanner Go client, and reports metrics and traces for the outgoing requests.
profiler
hotapp
Sample hotapp is a synthetic application that exhibits different types of profiling hotspots: CPU, heap allocations, thread contention.
Sample hotapp is a synthetic application that exhibits different types of profiling hotspots: CPU, heap allocations, thread contention.
profiler_quickstart
Sample profiler_quickstart simulates a CPU-intensive workload for profiler.
Sample profiler_quickstart simulates a CPU-intensive workload for profiler.
snippets
snippets is an example of starting cloud.google.com/go/profiler.
snippets is an example of starting cloud.google.com/go/profiler.
pubsub
pubsub_quickstart
[START pubsub_quickstart_create_topic] Sample pubsub-quickstart creates a Google Cloud Pub/Sub topic.
[START pubsub_quickstart_create_topic] Sample pubsub-quickstart creates a Google Cloud Pub/Sub topic.
subscriptions
Command subscriptions is a tool to manage Google Cloud Pub/Sub subscriptions by using the Pub/Sub API.
Command subscriptions is a tool to manage Google Cloud Pub/Sub subscriptions by using the Pub/Sub API.
topics
Command topics is a tool to manage Google Cloud Pub/Sub topics by using the Pub/Sub API.
Command topics is a tool to manage Google Cloud Pub/Sub topics by using the Pub/Sub API.
spanner
spanner_arrays
Sample spanner_arrays is a demonstration program which queries Google's Cloud Spanner and returns results containing arrays.
Sample spanner_arrays is a demonstration program which queries Google's Cloud Spanner and returns results containing arrays.
spanner_quickstart
Sample spanner_quickstart is a basic program that uses Cloud Spanner.
Sample spanner_quickstart is a basic program that uses Cloud Spanner.
spanner_snippets
Command spanner_snippets contains runnable snippet code for Cloud Spanner.
Command spanner_snippets contains runnable snippet code for Cloud Spanner.
speech
caption
Command caption sends audio data to the Google Speech API and prints its transcript.
Command caption sends audio data to the Google Speech API and prints its transcript.
captionasync
Command captionasync sends audio data to the Google Speech API and prints its transcript.
Command captionasync sends audio data to the Google Speech API and prints its transcript.
livecaption
Command livecaption pipes the stdin audio data to Google Speech API and outputs the transcript.
Command livecaption pipes the stdin audio data to Google Speech API and outputs the transcript.
speech_quickstart
[START speech_quickstart] Sample speech-quickstart uses the Google Cloud Speech API to transcribe audio.
[START speech_quickstart] Sample speech-quickstart uses the Google Cloud Speech API to transcribe audio.
wordoffset
Command wordoffset sends audio data to the Google Speech API and prints word offset information.
Command wordoffset sends audio data to the Google Speech API and prints word offset information.
storage
buckets
Sample buckets creates a bucket, lists buckets and deletes a bucket using the Google Storage API.
Sample buckets creates a bucket, lists buckets and deletes a bucket using the Google Storage API.
gcsupload
gcsupload is a CLI to upload a file to Google Cloud Storage.
gcsupload is a CLI to upload a file to Google Cloud Storage.
storage_quickstart
[START storage_quickstart] Sample storage-quickstart creates a Google Cloud Storage bucket.
[START storage_quickstart] Sample storage-quickstart creates a Google Cloud Storage bucket.
testing
gimmeproj
Command gimmeproj provides access to a pool of projects.
Command gimmeproj provides access to a pool of projects.
trace
trace_quickstart
Sample trace_quickstart creates traces incoming and outgoing requests.
Sample trace_quickstart creates traces incoming and outgoing requests.
translate
translate_quickstart
[START translate_quickstart] Sample translate-quickstart translates "Hello, world!" into Russian.
[START translate_quickstart] Sample translate-quickstart translates "Hello, world!" into Russian.
videointelligence
video_analyze
Command video_analyze uses the Google Cloud Video Intelligence API to analyze a video.
Command video_analyze uses the Google Cloud Video Intelligence API to analyze a video.
video_quickstart
Sample video_quickstart uses the Google Cloud Video Intelligence API to label a video.
Sample video_quickstart uses the Google Cloud Video Intelligence API to label a video.
vision
detect
Command detect uses the Vision API's label detection capabilities to find a label based on an image's content.
Command detect uses the Vision API's label detection capabilities to find a label based on an image's content.
label
Command label uses the Vision API's label detection capabilities to find a label based on an image's content.
Command label uses the Vision API's label detection capabilities to find a label based on an image's content.
vision_quickstart
[START vision_quickstart] Sample vision-quickstart uses the Google Cloud Vision API to label an image.
[START vision_quickstart] Sample vision-quickstart uses the Google Cloud Vision API to label an image.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL