2018-04-18 17:55:50 -04:00
# Google Cloud Client Libraries for Go
2017-03-06 04:17:55 -05:00
2022-03-10 16:26:02 -05:00
[![Go Reference ](https://pkg.go.dev/badge/cloud.google.com/go.svg )](https://pkg.go.dev/cloud.google.com/go)
2017-03-06 04:17:55 -05:00
2018-04-18 17:55:50 -04:00
Go packages for [Google Cloud Platform ](https://cloud.google.com ) services.
2017-03-06 04:17:55 -05:00
``` go
import "cloud.google.com/go"
```
2022-01-10 06:01:48 -05:00
To install the packages on your system, *do not clone the repo* . Instead:
2017-03-06 04:17:55 -05:00
2022-01-10 06:01:48 -05:00
1. Change to your project directory:
2022-02-17 17:49:31 -05:00
```bash
2022-01-10 06:01:48 -05:00
cd /my/cloud/project
```
1. Get the package you want to use. Some products have their own module, so it's
best to `go get` the package(s) you want to use:
```
$ go get cloud.google.com/go/firestore # Replace with the package you want to use.
```
2017-03-06 04:17:55 -05:00
2018-04-18 17:55:50 -04:00
**NOTE:** Some of these packages are under development, and may occasionally
make backwards-incompatible changes.
2017-03-06 04:17:55 -05:00
2018-04-18 17:55:50 -04:00
## Supported APIs
2022-03-10 16:26:02 -05:00
| Google API | Status | Package |
| ----------------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------- |
| [Asset][cloud-asset] | stable | [`cloud.google.com/go/asset/apiv1` ](https://pkg.go.dev/cloud.google.com/go/asset/v1beta ) |
| [Automl][cloud-automl] | stable | [`cloud.google.com/go/automl/apiv1` ](https://pkg.go.dev/cloud.google.com/go/automl/apiv1 ) |
| [BigQuery][cloud-bigquery] | stable | [`cloud.google.com/go/bigquery` ](https://pkg.go.dev/cloud.google.com/go/bigquery ) |
| [Bigtable][cloud-bigtable] | stable | [`cloud.google.com/go/bigtable` ](https://pkg.go.dev/cloud.google.com/go/bigtable ) |
| [Cloudbuild][cloud-build] | stable | [`cloud.google.com/go/cloudbuild/apiv1` ](https://pkg.go.dev/cloud.google.com/go/cloudbuild/apiv1 ) |
| [Cloudtasks][cloud-tasks] | stable | [`cloud.google.com/go/cloudtasks/apiv2` ](https://pkg.go.dev/cloud.google.com/go/cloudtasks/apiv2 ) |
2022-02-17 17:49:31 -05:00
| [Compute Engine][cloud-compute] | alpha | [`cloud.google.com/go/compute/apiv1` ](https://pkg.go.dev/cloud.google.com/go/compute/apiv1 ) |
2022-03-10 16:26:02 -05:00
| [Container][cloud-container] | stable | [`cloud.google.com/go/container/apiv1` ](https://pkg.go.dev/cloud.google.com/go/container/apiv1 ) |
| [ContainerAnalysis][cloud-containeranalysis] | beta | [`cloud.google.com/go/containeranalysis/apiv1` ](https://pkg.go.dev/cloud.google.com/go/containeranalysis/apiv1 ) |
| [Dataproc][cloud-dataproc] | stable | [`cloud.google.com/go/dataproc/apiv1` ](https://pkg.go.dev/cloud.google.com/go/dataproc/apiv1 ) |
| [Datastore][cloud-datastore] | stable | [`cloud.google.com/go/datastore` ](https://pkg.go.dev/cloud.google.com/go/datastore ) |
| [Debugger][cloud-debugger] | stable | [`cloud.google.com/go/debugger/apiv2` ](https://pkg.go.dev/cloud.google.com/go/debugger/apiv2 ) |
| [Dialogflow][cloud-dialogflow] | stable | [`cloud.google.com/go/dialogflow/apiv2` ](https://pkg.go.dev/cloud.google.com/go/dialogflow/apiv2 ) |
| [Data Loss Prevention][cloud-dlp] | stable | [`cloud.google.com/go/dlp/apiv2` ](https://pkg.go.dev/cloud.google.com/go/dlp/apiv2 ) |
| [ErrorReporting][cloud-errors] | alpha | [`cloud.google.com/go/errorreporting` ](https://pkg.go.dev/cloud.google.com/go/errorreporting ) |
| [Firestore][cloud-firestore] | stable | [`cloud.google.com/go/firestore` ](https://pkg.go.dev/cloud.google.com/go/firestore ) |
| [IAM][cloud-iam] | stable | [`cloud.google.com/go/iam` ](https://pkg.go.dev/cloud.google.com/go/iam ) |
| [IoT][cloud-iot] | stable | [`cloud.google.com/go/iot/apiv1` ](https://pkg.go.dev/cloud.google.com/go/iot/apiv1 ) |
| [IRM][cloud-irm] | alpha | [`cloud.google.com/go/irm/apiv1alpha2` ](https://pkg.go.dev/cloud.google.com/go/irm/apiv1alpha2 ) |
| [KMS][cloud-kms] | stable | [`cloud.google.com/go/kms/apiv1` ](https://pkg.go.dev/cloud.google.com/go/kms/apiv1 ) |
| [Natural Language][cloud-natural-language] | stable | [`cloud.google.com/go/language/apiv1` ](https://pkg.go.dev/cloud.google.com/go/language/apiv1 ) |
| [Logging][cloud-logging] | stable | [`cloud.google.com/go/logging` ](https://pkg.go.dev/cloud.google.com/go/logging ) |
| [Memorystore][cloud-memorystore] | alpha | [`cloud.google.com/go/redis/apiv1` ](https://pkg.go.dev/cloud.google.com/go/redis/apiv1 ) |
| [Monitoring][cloud-monitoring] | stable | [`cloud.google.com/go/monitoring/apiv3` ](https://pkg.go.dev/cloud.google.com/go/monitoring/apiv3 ) |
| [OS Login][cloud-oslogin] | stable | [`cloud.google.com/go/oslogin/apiv1` ](https://pkg.go.dev/cloud.google.com/go/oslogin/apiv1 ) |
| [Pub/Sub][cloud-pubsub] | stable | [`cloud.google.com/go/pubsub` ](https://pkg.go.dev/cloud.google.com/go/pubsub ) |
2022-02-17 17:49:31 -05:00
| [Pub/Sub Lite][cloud-pubsublite] | stable | [`cloud.google.com/go/pubsublite` ](https://pkg.go.dev/cloud.google.com/go/pubsublite ) |
2022-03-10 16:26:02 -05:00
| [Phishing Protection][cloud-phishingprotection] | alpha | [`cloud.google.com/go/phishingprotection/apiv1beta1` ](https://pkg.go.dev/cloud.google.com/go/phishingprotection/apiv1beta1 ) |
| [reCAPTCHA Enterprise][cloud-recaptcha] | alpha | [`cloud.google.com/go/recaptchaenterprise/apiv1beta1` ](https://pkg.go.dev/cloud.google.com/go/recaptchaenterprise/apiv1beta1 ) |
| [Recommender][cloud-recommender] | beta | [`cloud.google.com/go/recommender/apiv1beta1` ](https://pkg.go.dev/cloud.google.com/go/recommender/apiv1beta1 ) |
| [Scheduler][cloud-scheduler] | stable | [`cloud.google.com/go/scheduler/apiv1` ](https://pkg.go.dev/cloud.google.com/go/scheduler/apiv1 ) |
| [Securitycenter][cloud-securitycenter] | stable | [`cloud.google.com/go/securitycenter/apiv1` ](https://pkg.go.dev/cloud.google.com/go/securitycenter/apiv1 ) |
| [Spanner][cloud-spanner] | stable | [`cloud.google.com/go/spanner` ](https://pkg.go.dev/cloud.google.com/go/spanner ) |
| [Speech][cloud-speech] | stable | [`cloud.google.com/go/speech/apiv1` ](https://pkg.go.dev/cloud.google.com/go/speech/apiv1 ) |
| [Storage][cloud-storage] | stable | [`cloud.google.com/go/storage` ](https://pkg.go.dev/cloud.google.com/go/storage ) |
| [Talent][cloud-talent] | alpha | [`cloud.google.com/go/talent/apiv4beta1` ](https://pkg.go.dev/cloud.google.com/go/talent/apiv4beta1 ) |
| [Text To Speech][cloud-texttospeech] | stable | [`cloud.google.com/go/texttospeech/apiv1` ](https://pkg.go.dev/cloud.google.com/go/texttospeech/apiv1 ) |
| [Trace][cloud-trace] | stable | [`cloud.google.com/go/trace/apiv2` ](https://pkg.go.dev/cloud.google.com/go/trace/apiv2 ) |
| [Translate][cloud-translate] | stable | [`cloud.google.com/go/translate` ](https://pkg.go.dev/cloud.google.com/go/translate ) |
| [Video Intelligence][cloud-video] | beta | [`cloud.google.com/go/videointelligence/apiv1beta2` ](https://pkg.go.dev/cloud.google.com/go/videointelligence/apiv1beta2 ) |
| [Vision][cloud-vision] | stable | [`cloud.google.com/go/vision/apiv1` ](https://pkg.go.dev/cloud.google.com/go/vision/apiv1 ) |
| [Webrisk][cloud-webrisk] | alpha | [`cloud.google.com/go/webrisk/apiv1beta1` ](https://pkg.go.dev/cloud.google.com/go/webrisk/apiv1beta1 ) |
2018-04-18 17:55:50 -04:00
> **Alpha status**: the API is still being actively developed. As a
2017-03-06 04:17:55 -05:00
> result, it might change in backward-incompatible ways and is not recommended
> for production use.
>
> **Beta status**: the API is largely complete, but still has outstanding
> features and bugs to be addressed. There may be minor backwards-incompatible
> changes where necessary.
>
> **Stable status**: the API is mature and ready for production use. We will
> continue addressing bugs and feature requests.
2022-01-10 06:01:48 -05:00
Documentation and examples are available at [pkg.go.dev/cloud.google.com/go ](https://pkg.go.dev/cloud.google.com/go )
2017-03-06 04:17:55 -05:00
2022-03-10 16:26:02 -05:00
## [Go Versions Supported](#supported-versions)
2017-03-06 04:17:55 -05:00
2022-03-10 16:26:02 -05:00
We currently support Go versions 1.11 and newer.
2017-03-06 04:17:55 -05:00
## Authorization
2019-08-26 09:47:02 -04:00
By default, each API will use [Google Application Default Credentials ](https://developers.google.com/identity/protocols/application-default-credentials )
2017-03-06 04:17:55 -05:00
for authorization credentials used in calling the API endpoints. This will allow your
application to run in many environments without requiring explicit configuration.
2018-04-18 17:55:50 -04:00
[snip]:# (auth)
```go
client, err := storage.NewClient(ctx)
```
2017-03-06 04:17:55 -05:00
To authorize using a
[JSON key file ](https://cloud.google.com/iam/docs/managing-service-account-keys ),
pass
2022-01-10 06:01:48 -05:00
[`option.WithCredentialsFile` ](https://pkg.go.dev/google.golang.org/api/option#WithCredentialsFile )
2017-03-06 04:17:55 -05:00
to the `NewClient` function of the desired package. For example:
2018-04-18 17:55:50 -04:00
[snip]:# (auth-JSON)
2017-03-06 04:17:55 -05:00
```go
2019-08-26 09:47:02 -04:00
client, err := storage.NewClient(ctx, option.WithCredentialsFile("path/to/keyfile.json"))
2017-03-06 04:17:55 -05:00
```
You can exert more control over authorization by using the
2022-01-10 06:01:48 -05:00
[`golang.org/x/oauth2` ](https://pkg.go.dev/golang.org/x/oauth2 ) package to
2017-03-06 04:17:55 -05:00
create an `oauth2.TokenSource` . Then pass
2022-01-10 06:01:48 -05:00
[`option.WithTokenSource` ](https://pkg.go.dev/google.golang.org/api/option#WithTokenSource )
2017-03-06 04:17:55 -05:00
to the `NewClient` function:
2018-04-18 17:55:50 -04:00
[snip]:# (auth-ts)
2017-03-06 04:17:55 -05:00
```go
tokenSource := ...
client, err := storage.NewClient(ctx, option.WithTokenSource(tokenSource))
```
## Contributing
Contributions are welcome. Please, see the
[CONTRIBUTING ](https://github.com/GoogleCloudPlatform/google-cloud-go/blob/master/CONTRIBUTING.md )
2022-01-10 06:01:48 -05:00
document for details.
2017-03-06 04:17:55 -05:00
Please note that this project is released with a Contributor Code of Conduct.
By participating in this project you agree to abide by its terms.
See [Contributor Code of Conduct ](https://github.com/GoogleCloudPlatform/google-cloud-go/blob/master/CONTRIBUTING.md#contributor-code-of-conduct )
for more information.
2022-01-10 06:01:48 -05:00
[cloud-asset]: https://cloud.google.com/security-command-center/docs/how-to-asset-inventory
[cloud-automl]: https://cloud.google.com/automl
[cloud-build]: https://cloud.google.com/cloud-build/
2017-03-06 04:17:55 -05:00
[cloud-bigquery]: https://cloud.google.com/bigquery/
2022-01-10 06:01:48 -05:00
[cloud-bigtable]: https://cloud.google.com/bigtable/
2022-02-17 17:49:31 -05:00
[cloud-compute]: https://cloud.google.com/compute
2018-04-18 17:55:50 -04:00
[cloud-container]: https://cloud.google.com/containers/
2022-01-10 06:01:48 -05:00
[cloud-containeranalysis]: https://cloud.google.com/container-registry/docs/container-analysis
[cloud-dataproc]: https://cloud.google.com/dataproc/
[cloud-datastore]: https://cloud.google.com/datastore/
[cloud-dialogflow]: https://cloud.google.com/dialogflow-enterprise/
2018-04-18 17:55:50 -04:00
[cloud-debugger]: https://cloud.google.com/debugger/
[cloud-dlp]: https://cloud.google.com/dlp/
2022-01-10 06:01:48 -05:00
[cloud-errors]: https://cloud.google.com/error-reporting/
[cloud-firestore]: https://cloud.google.com/firestore/
2019-08-26 09:47:02 -04:00
[cloud-iam]: https://cloud.google.com/iam/
2022-01-10 06:01:48 -05:00
[cloud-iot]: https://cloud.google.com/iot-core/
[cloud-irm]: https://cloud.google.com/incident-response/docs/concepts
2019-08-26 09:47:02 -04:00
[cloud-kms]: https://cloud.google.com/kms/
2022-01-10 06:01:48 -05:00
[cloud-pubsub]: https://cloud.google.com/pubsub/
2022-03-10 16:26:02 -05:00
[cloud-pubsublite]: https://cloud.google.com/pubsub/lite
2022-01-10 06:01:48 -05:00
[cloud-storage]: https://cloud.google.com/storage/
[cloud-language]: https://cloud.google.com/natural-language
[cloud-logging]: https://cloud.google.com/logging/
2019-08-26 09:47:02 -04:00
[cloud-natural-language]: https://cloud.google.com/natural-language/
[cloud-memorystore]: https://cloud.google.com/memorystore/
2022-01-10 06:01:48 -05:00
[cloud-monitoring]: https://cloud.google.com/monitoring/
[cloud-oslogin]: https://cloud.google.com/compute/docs/oslogin/rest
[cloud-phishingprotection]: https://cloud.google.com/phishing-protection/
[cloud-securitycenter]: https://cloud.google.com/security-command-center/
[cloud-scheduler]: https://cloud.google.com/scheduler
[cloud-spanner]: https://cloud.google.com/spanner/
[cloud-speech]: https://cloud.google.com/speech
[cloud-talent]: https://cloud.google.com/solutions/talent-solution/
[cloud-tasks]: https://cloud.google.com/tasks/
2019-08-26 09:47:02 -04:00
[cloud-texttospeech]: https://cloud.google.com/texttospeech/
2022-01-10 06:01:48 -05:00
[cloud-talent]: https://cloud.google.com/solutions/talent-solution/
2019-08-26 09:47:02 -04:00
[cloud-trace]: https://cloud.google.com/trace/
2022-01-10 06:01:48 -05:00
[cloud-translate]: https://cloud.google.com/translate
2019-08-26 09:47:02 -04:00
[cloud-recaptcha]: https://cloud.google.com/recaptcha-enterprise/
2022-01-10 06:01:48 -05:00
[cloud-recommender]: https://cloud.google.com/recommendations/
[cloud-video]: https://cloud.google.com/video-intelligence/
[cloud-vision]: https://cloud.google.com/vision
[cloud-webrisk]: https://cloud.google.com/web-risk/
2022-03-10 16:26:02 -05:00
## Links
- [Go on Google Cloud ](https://cloud.google.com/go/home )
- [Getting started with Go on Google Cloud ](https://cloud.google.com/go/getting-started )
- [App Engine Quickstart ](https://cloud.google.com/appengine/docs/standard/go/quickstart )
- [Cloud Functions Quickstart ](https://cloud.google.com/functions/docs/quickstart-go )
- [Cloud Run Quickstart ](https://cloud.google.com/run/docs/quickstarts/build-and-deploy#go )