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 in two ways:
- Relative to the directory that contains the module's
- Relative to the src subdirectory of all the directories in
GOPATH(this is called a "fully-qualifed" import path).
For example, if
GOPATH is defined this way:
And the file
src1-1.go in the project directory example above contains this
The SDK will look for the package "foo/bar" in these locations when you run or deploy module1:
If you include your package sources in
GOPATH, you must be careful not to
place the source code at or below any directories in your App Engine project
app.yaml files. If that happens, a package could be loaded twice,
once for the path relative to a module's directory, and once for the
fully-qualified path. This can cause subtle problems, so the Go SDK scans your
project and your
GOPATH, detects this case, and reports it as an error.
For best results, we recommend the following:
- Create a separate directory in your project for each module.
- Each module directory should contain the module's
app.yamlfile and one or more
- Do not include any subdirectories in a module's directory.
.gofiles should import packages using fully-qualified paths; place all package code beneath src directories that are direct children of the project directory, or not under your project directory at all.
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 libraries required by your app along with your application code. For complete details on what you need to do, see Deploying your application.