Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Nesta página, descrevemos como instalar e usar os serviços
incluídos com o ambiente de execução do Go
no ambiente padrão do App Engine. O aplicativo pode acessar os serviços incluídos
pelo SDK de serviços do App Engine para Go.
Para chamar as APIs legadas de serviços incluídos com o Go ou versões mais recentes,
é necessário usar o SDK mais recente. Siga estas etapas:
Atualize o arquivo app.yaml para incluir esta linha:
app_engine_apis:true
Adicione uma referência ao SDK mais recente no go.mod executando go get no terminal da seguinte maneira:
gogetgoogle.golang.org/appengine/v2
A principal diferença ao fazer upgrade para o Go ou versões mais recente é usar a v2 do SDK de serviços do App Engine.
No app, modifique as instruções de importação inserindo /v2/ nos nomes
de pacotes antigos. Por exemplo, se você estiver usando o Memcache, faça o seguinte:
Execute go mod tidy para limpar as referências no arquivo go.mod.
gomodtidy
Considerações sobre a migração
Esteja ciente das seguintes considerações se você estiver migrando para o
ambiente de execução do Go e se o aplicativo usar serviços incluídos legados:
Para testar a funcionalidade dos serviços incluídos legados no aplicativo Go,
execute o aplicativo no ambiente local
com as ferramentas de desenvolvimento que você costuma usar, como go run.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-04-21 UTC."],[[["\u003cp\u003eThis guide outlines the process of installing and utilizing the App Engine services SDK for Go, enabling access to legacy bundled services within the App Engine standard environment.\u003c/p\u003e\n"],["\u003cp\u003eTo begin, you must update your \u003ccode\u003eapp.yaml\u003c/code\u003e file to include \u003ccode\u003eapp_engine_apis: true\u003c/code\u003e and ensure you are using the latest SDK by referencing \u003ccode\u003egoogle.golang.org/appengine/v2\u003c/code\u003e in your \u003ccode\u003ego.mod\u003c/code\u003e file.\u003c/p\u003e\n"],["\u003cp\u003eWhen updating from older SDK versions, the key change is the inclusion of \u003ccode\u003e/v2/\u003c/code\u003e in import statements within your Go application code, such as \u003ccode\u003egoogle.golang.org/appengine/v2/memcache\u003c/code\u003e for Memcache.\u003c/p\u003e\n"],["\u003cp\u003eBefore beginning migration to Go, be sure to review the runtime migration overview and make yourself aware of the migration considerations.\u003c/p\u003e\n"],["\u003cp\u003eTesting of legacy bundled services in a Go application can be performed locally using tools like \u003ccode\u003ego run\u003c/code\u003e, and deployment is achieved using the \u003ccode\u003egcloud app deploy\u003c/code\u003e command.\u003c/p\u003e\n"]]],[],null,["# Access legacy bundled services for Go\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\nThis page describes how to install and use the bundled\nservices with the [Go runtime](/appengine/docs/standard/go/runtime)\nfor App Engine standard environment. Your app can access the bundled services\nthrough the **App Engine services SDK for Go**.\n\nBefore you begin\n----------------\n\n- Refer to the [list of legacy bundled services APIs](/appengine/docs/standard/services/overview) you can call in the Go runtime.\n- Before starting a migration project to Go, see the [runtime migration overview](/appengine/migration-center/standard/migrate-to-second-gen/go-differences) and [migration considerations](#migration) when using legacy bundled services.\n\nInstalling the App Engine services SDK\n--------------------------------------\n\nIn order to call the legacy bundled services APIs with Go, you\nmust use the latest SDK. Follow these steps:\n\n1. Update your [`app.yaml`](/appengine/docs/standard/reference/app-yaml#app_engine_apis)\n file to include the following line:\n\n app_engine_apis: true\n\n2. Add a reference to the latest SDK in your `go.mod` file by running `go get`\n in the terminal as follows:\n\n go get google.golang.org/appengine/v2\n\n The main difference when upgrading to Go is using v2 of the App Engine services SDK.\n3. In your app, modify your import statements by inserting `/v2/` in the old\n package names. For example, if using Memcache, do the following:\n\n import (\n \"google.golang.org/appengine/v2\"\n \"google.golang.org/appengine/v2/memcache\"\n )\n\n For the full list of available package names, see the\n [legacy bundled services API references documentation](/appengine/docs/standard/go/reference/services/bundled/latest).\n4. Run `go mod tidy` to clean up references in your `go.mod` file.\n\n go mod tidy\n\n| **Note:** When upgrading to a new major version of a Go dependency, such as a package or library, make sure to include the major version number of the dependency in your import statements. If you run `go mod tidy` and find that it is still importing an older version of the App Engine services SDK for Go, you have probably missed upgrading an import statement.\n\nMigration considerations\n------------------------\n\nYou should be aware of the following considerations if you are migrating to\nthe Go runtime and your app uses legacy bundled services:\n\n- To test the legacy bundled services functionality in your Go app, [run your application in your local environment](/appengine/docs/standard/testing-and-deploying-your-app#running_locally) with the development tools that you usually use, such as `go run`.\n- To deploy your app, use the [`gcloud app deploy`](/appengine/docs/standard/go/building-app#deploying_your_web_service_on) command."]]