Go 1.11 has reached end of support
and will be
deprecated
on January 31, 2026. After deprecation, you won't be able to deploy Go 1.11
applications, even if your organization previously used an organization policy to
re-enable deployments of legacy runtimes. Your existing Go
1.11 applications will continue to run and receive traffic after their
deprecation date. We
recommend that you
migrate to the latest supported version of Go.
A Go Task Queue Example
Stay organized with collections
Save and categorize content based on your preferences.
This example creates an app that displays an HTML form. You enter
a string into the dialog box and click Add
. The app counts the number of times
that you enter any string in this way.
The app does these things:
- When you click
Add
, the form uses an HTTP POST
request to send the string
to the app which is running on App Engine. There the app bundles the string
into a task and sends it to the default queue.
- The queue forwards the task to an included task handler, mapped to the URL
/worker
,
which asynchronously writes the string to a datastore.
- Sending an HTTP
GET
request displays a list of the strings you have entered
and the number of times you haveAdd
ed each string, either by typing it or
by clicking on it in the dropdown box.
To deploy this app to App Engine:
Copy the following into a file named queue.yaml
. This changes the rate at
which tasks will be processed from the default 5 per second to 3 per second.
queue:
- name: default
rate: 3/s
In the same directory, copy the following into a file named as you like (ending in .go
). This is the application code, including the task handler.
In the same directory, copy the following into a file named app.yaml
. This configures your
application for App Engine:
Make sure you have a Google Cloud Platform project with an App Engine app
prepared and that you have initialized and
configured the gcloud
command for that project.
Use the gcloud app deploy
command to deploy the app to App Engine.
See the app in action by using the gcloud app browse
command.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-04 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-04 UTC."],[[["This application counts and displays the number of times a string is entered via an HTML form."],["When a string is added, it's sent to App Engine via an HTTP POST request, bundled into a task, and added to the default queue."],["The task queue forwards the task to a worker handler, which then writes the string to a datastore asynchronously."],["An HTTP GET request retrieves and displays a list of the entered strings and their corresponding counts."],["The application can be deployed to App Engine using specific configuration files and the `gcloud` command-line tool."]]],[]]