Prepare your environment for
[Go](https://golang.org/)
app development and deployment on Google Cloud by installing
the following tools.

## Install Go

1. To install Go, see [Go Getting Started](https://golang.org/doc/install).

2. Confirm that you have the most recent version of Go installed:

   ```go
   go version
   ```

## Install an editor

To maximize your Go development efficacy, these
[popular editor plugins and IDEs](https://golang.org/doc/editors.html)
provide the following features:

- Fully integrated debugging capabilities
- Syntax highlighting
- Code completion

## Install the Google Cloud CLI

The [Google Cloud CLI](https://docs.cloud.google.com/sdk)
is a set of tools for Google Cloud. It contains the
[`gcloud`](https://docs.cloud.google.com/sdk/gcloud.md.txt)
and [`bq`](https://docs.cloud.google.com/bigquery/docs/bq-command-line-tool)
command-line tools used to access Compute Engine, Cloud Storage,
BigQuery, and other services from the command line. You can run these
tools interactively or in your automated scripts.
For example, to [deploy a Go web app](https://docs.cloud.google.com/appengine/docs/standard/go/create-app) with a `main` package to App Engine, run the following command:

<br />

```go
gcloud app deploy
```

To install the gcloud CLI, see [Installing the gcloud CLI](https://docs.cloud.google.com/sdk/install).


## Install the Cloud Client Libraries for Go

The [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go)
is the idiomatic way for Go developers to integrate with
Google Cloud services, such as Datastore and Cloud Storage.

For example, to install the package for an individual API, such as the Cloud Storage API,
do the following:

1. If you already have a Go module for your project, change to that directory.
   Otherwise, create a module:

   ```
   go mod init YOUR_MODULE_NAME
   ```

   <br />

   Replace `YOUR_MODULE_NAME` with the name of the new module.
2. Use the Cloud Storage package in your project:

   ```
   go get cloud.google.com/go/storage
   ```

   <br />

   > [!NOTE]
   > **Note:** The source of the Cloud Client Libraries for Go is [on GitHub](https://github.com/googleapis/google-cloud-go)

## Set up authentication

To use the Cloud Client Libraries in a local development environment, set
up Application Default Credentials.


If you're using a local shell, then create local authentication credentials for your user
account:

```bash
gcloud auth application-default login
```

You don't need to do this if you're using Cloud Shell.


If an authentication error is returned, and you are using an external identity provider
(IdP), confirm that you have
[signed in to the gcloud CLI with your federated identity](https://docs.cloud.google.com/iam/docs/workforce-log-in-gcloud.md.txt).

For more information, see
[Authenticate for using client libraries](https://docs.cloud.google.com/docs/authentication/client-libraries.md.txt).

## (Optional) Observability

[Google Cloud Observability](https://docs.cloud.google.com/stackdriver) include observability services that help you
understand the behavior, health, and performance of your Go
applications. For more information, see
[Google Cloud Observability for Go](https://docs.cloud.google.com/go/docs/stackdriver.md.txt).

## Install other useful tools

For a comprehensive list of Go tools and libraries, see
[this list of Go frameworks, libraries, and software on GitHub](https://github.com/avelino/awesome-go).

## What's next

- Learn more about [Go on Google Cloud](https://docs.cloud.google.com/go).

- Deploy a Go app on [App Engine](https://docs.cloud.google.com/appengine/docs/standard/go/create-app).

- Explore [authentication methods at Google](https://docs.cloud.google.com/docs/authentication.md.txt).

- Browse the [documentation for Google Cloud products](https://docs.cloud.google.com/products).

- Clone the [Go samples repository from GitHub](https://github.com/GoogleCloudPlatform/golang-samples).