Setting up your development environment (original) (raw)

Prepare your environment forGoapp development and deployment on Google Cloud by installing the following tools.

Install Go

  1. To install Go, see Go Getting Started.
  2. Confirm that you have the most recent version of Go installed:
go version  

Install an editor

To maximize your Go development efficacy, thesepopular editor plugins and IDEsprovide the following features:

Install the Google Cloud CLI

The Google Cloud CLIis a set of tools for Google Cloud. It contains thegcloudand bqcommand-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 with a mainpackage to App Engine, run the following command:

gcloud app deploy

To install the gcloud CLI, see Installing the gcloud CLI.

Install the Cloud Client Libraries for Go

The Cloud Client Libraries for Gois 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
    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

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:

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.

For more information, seeAuthenticate for using client libraries.

For a comprehensive list of Go tools and libraries, seethis list of Go frameworks, libraries, and software on GitHub.

What's next