blob: 33191531aab83543926b5d5d297bfc825a46bbfe [file] [log] [blame]
Announcing App Engines New Go 1.11 Runtime
16 Oct 2018
Tags: appengine
Eno Compton
Tyler Bui-Palsulich
* Background
[[https://cloud.google.com/appengine/][App Engine]] launched
[[https://blog.golang.org/go-and-google-app-engine][experimental support for Go]]
in 2011. In the subsequent years, the Go community has grown significantly and
has settled on idiomatic
patterns for cloud-based applications. Today, Google Cloud is
[[https://cloud.google.com/blog/products/application-development/go-1-11-is-now-available-on-app-engine][announcing a new Go 1.11 runtime]]
for the App Engine standard environment that provides all the
power of App Enginethings like paying only for what you use, automatic scaling,
and managed infrastructurewhile supporting idiomatic Go.
Starting with Go 1.11, Go on App Engine has no limits on application structure,
supported packages, `context.Context` values, or HTTP clients. Write your Go
application however you prefer, add an `app.yaml` file, and your app is ready
to deploy on App Engine.
[[https://cloud.google.com/appengine/docs/standard/go111/specifying-dependencies][Specifying Dependencies]]
describes how the new runtime
supports [[https://golang.org/cmd/go/#hdr-Vendor_Directories][vendoring]] and
[[https://golang.org/doc/go1.11#modules][modules]] (experimental) for dependency
management.
Along with [[https://twitter.com/kelseyhightower/status/1035278586754813952][Cloud Functions support for Go]]
(more on that in a future post), App Engine provides a compelling way to run Go
code on Google Cloud Platform (GCP) with no concern for the underlying
infrastructure.
Lets take a look at creating a small application for App Engine. For the
example here, we assume a `GOPATH`-based workflow, although Go modules have
[[https://cloud.google.com/appengine/docs/standard/go111/specifying-dependencies][experimental support]]
as well.
First, you create the application in your `GOPATH`:
.code appengine/main.go
The code contains an idiomatic setup for a small HTTP server that responds with
Hello, 世界.” If you have previous App Engine experience, youll notice the
absence of any call to `appengine.Main()`, which is now entirely optional.
Furthermore, the application code is completely portablethere are no ties to
the infrastructure that your application is deployed on.
If you need to use external dependencies, you can add those dependencies to a
`vendor` directory or to a `go.mod` file, both of which the new runtime
supports.
With the application code complete, create an `app.yaml` file to specify
the runtime:
runtime: go111
Finally, set your machine up with a Google Cloud Platform account:
- Create an account with [[GCP][https://cloud.google.com]].
- [[https://cloud.google.com/resource-manager/docs/creating-managing-projects][Create a project]].
- Install the [[https://cloud.google.com/sdk/][Cloud SDK]] on your system.
With all the setup complete, you can deploy using one command:
gcloud app deploy
We think Go developers will find the new Go 1.11 runtime for App Engine an
exciting addition to the available options to run Go applications. There is a
[[https://cloud.google.com/free/][free tier]]. Check out the
[[https://cloud.google.com/appengine/docs/standard/go111/building-app/][getting started guide]]
or the
[[https://cloud.google.com/appengine/docs/standard/go111/go-differences][migration guide]]
and deploy an app to the new runtime today!