You can use any linux/amd64-compatible package with instances running in the
App Engine flexible environment. These instructions assume you are using the
go get command to get the packages directly from supported repositories, such
as GitHub, Bitbucket, LaunchPad, etc.
Declaring and managing dependencies
Go applications are organized into packages that mirror the directory structure
of your source files. When you use an import statement, the relative paths in
the import are interpreted. Valid import paths are fully-qualified
paths that are relative to the
src subdirectory of all the directories that
are specified in your
For example, if
GOPATH is defined as follows:
src1-1.go file in the example app's directory contains the following
gcloud tool will look for the "foo/bar" package in the
following location when you run or deploy the app:
If you include your package sources in
GOPATH, you must be careful not to
place your source code at or below your app's directory where the
file is located. If that happens, subtle problems can occur because a package
might get loaded twice, once for the path relative to a service's directory, and
once again for the fully-qualified path. To avoid problems, the
will scan both your app's directory and
GOPATH, and then report an error
if a conflict is detected.
For best results, we recommend the following:
- Create a separate directory in your app's directory for each service.
- Each service's directory should contain the service's
app.yamlfile and one or more
- Do not include any subdirectories in a service's directory.
GOPATHshould specify a directory that is outside your app's directory and contain all the dependencies that your app imports.
Downloading required packages
You can use the
go get command to download packages. For example, to download
packagename from the GitHub
go get github.com/my_repo/packagename
Deploying to App Engine
In order to deploy your application to App Engine, you'll need to deploy the libraries that are required by your app along with your application code. For complete details, see Deploying your application.