...

Text file src/cloud.google.com/go/README.md

Documentation: cloud.google.com/go

     1# Google Cloud Client Libraries for Go
     2
     3[![Go Reference](https://pkg.go.dev/badge/cloud.google.com/go.svg)](https://pkg.go.dev/cloud.google.com/go)
     4
     5Go packages for [Google Cloud Platform](https://cloud.google.com) services.
     6
     7``` go
     8import "cloud.google.com/go"
     9```
    10
    11To install the packages on your system, *do not clone the repo*. Instead:
    12
    131. Change to your project directory: `cd /my/cloud/project`
    141. Get the package you want to use. Some products have their own module, so it's
    15   best to `go get` the package(s) you want to use:
    16
    17```bash
    18go get cloud.google.com/go/firestore # Replace with the package you want to use.
    19```
    20
    21**NOTE:** Some of these packages are under development, and may occasionally
    22make backwards-incompatible changes.
    23
    24## Supported APIs
    25
    26For an updated list of all of our released APIs please see our
    27[reference docs](https://cloud.google.com/go/docs/reference).
    28
    29## [Go Versions Supported](#supported-versions)
    30
    31Our libraries are compatible with at least the three most recent, major Go
    32releases. They are currently compatible with:
    33
    34- Go 1.22
    35- Go 1.21
    36- Go 1.20
    37- Go 1.19
    38
    39## Authorization
    40
    41By default, each API will use [Google Application Default Credentials](https://developers.google.com/identity/protocols/application-default-credentials)
    42for authorization credentials used in calling the API endpoints. This will allow your
    43application to run in many environments without requiring explicit configuration.
    44
    45```go
    46client, err := storage.NewClient(ctx)
    47```
    48
    49To authorize using a
    50[JSON key file](https://cloud.google.com/iam/docs/managing-service-account-keys),
    51pass
    52[`option.WithCredentialsFile`](https://pkg.go.dev/google.golang.org/api/option#WithCredentialsFile)
    53to the `NewClient` function of the desired package. For example:
    54
    55```go
    56client, err := storage.NewClient(ctx, option.WithCredentialsFile("path/to/keyfile.json"))
    57```
    58
    59You can exert more control over authorization by using the
    60[`golang.org/x/oauth2`](https://pkg.go.dev/golang.org/x/oauth2) package to
    61create an `oauth2.TokenSource`. Then pass
    62[`option.WithTokenSource`](https://pkg.go.dev/google.golang.org/api/option#WithTokenSource)
    63to the `NewClient` function:
    64
    65```go
    66tokenSource := ...
    67client, err := storage.NewClient(ctx, option.WithTokenSource(tokenSource))
    68```
    69
    70## Contributing
    71
    72Contributions are welcome. Please, see the
    73[CONTRIBUTING](https://github.com/GoogleCloudPlatform/google-cloud-go/blob/main/CONTRIBUTING.md)
    74document for details.
    75
    76Please note that this project is released with a Contributor Code of Conduct.
    77By participating in this project you agree to abide by its terms.
    78See [Contributor Code of Conduct](https://github.com/GoogleCloudPlatform/google-cloud-go/blob/main/CONTRIBUTING.md#contributor-code-of-conduct)
    79for more information.
    80
    81## Links
    82
    83- [Go on Google Cloud](https://cloud.google.com/go/home)
    84- [Getting started with Go on Google Cloud](https://cloud.google.com/go/getting-started)
    85- [App Engine Quickstart](https://cloud.google.com/appengine/docs/standard/go/quickstart)
    86- [Cloud Functions Quickstart](https://cloud.google.com/functions/docs/quickstart-go)
    87- [Cloud Run Quickstart](https://cloud.google.com/run/docs/quickstarts/build-and-deploy#go)

View as plain text