Go 1.12+ 표준 런타임에서 실행되는 앱은 모든 linux/amd64 호환 패키지를 사용할 수 있습니다.
App Engine에서는 Go 코드의 모든 가져오기 문에 절대 경로를 지정해야 합니다. 예를 들어 다음을 사용하세요.
import"github.com/example/mypackage"
Go 모듈 사용
Go 모듈을 사용하여 Go 앱에서 종속 항목을 관리하는 것이 좋지만 Go 모듈로 마이그레이션할 준비가 되지 않았다면 이전 GOPATH 모드를 계속 사용할 수 있습니다.
Go 버전 1.22 이상부터 다음과 같은 사항이 적용됩니다.
기존 GOPATH 모드(GO111MODULE=off)의 모듈 외부에서 go get을 사용할 수 없습니다. 자세한 내용은 도구를 참조하세요.
Go에서는 종속 항목 관리에 go.mod 파일을 사용하는 것이 좋습니다. 배포 중에 종속 항목을 설치하려면 go.mod 파일을 app.yaml 파일과 동일한 폴더에 포함합니다. Go 버전 및 공급업체 디렉터리의 종속 항목 관리에 관한 자세한 내용은 GOPATH 및 모듈을 참고하세요.
앱을 배포할 때 App Engine은 go build 명령어를 사용하여 앱을 빌드하며 Go의 동작 자체와 일치합니다. 앱에 module-aware 모드가 사용되도록 하려면 개발 환경에서 다음을 수행합니다.
app.yaml 파일과 동일한 디렉터리에 모듈의 go.mod 파일을 만듭니다. App Engine은 현재 디렉터리를 검색하고 go.mod 파일을 찾을 때까지 계속해서 그 다음 상위 디렉터리를 검색합니다.
App Engine이 go.mod 파일을 찾지 못하면 GOPATH 모드를 따릅니다.
GO111MODULE 환경 변수를 설정한 경우 변수 값이 module-aware 모드를 사용 설정하는지 확인합니다. 앱을 배포할 때 App Engine은 GO111MODULE 환경을 확인하고 Go 자체 동작을 찾습니다.
앱에 go.mod 파일이 포함되어 있으면 App Engine은 GO111MODULE 변수 설정만 적용합니다.
Go 1.12의 경우 앱 디렉터리를 $GOPATH/src 폴더 내에 배치하지 않습니다. Go 1.12 앱이 $GOPATH/src 디렉터리 트리에 있는 경우, App Engine은 앱에 go.mod 파일을 정의한 경우에도 GOPATH 모드를 따릅니다.
Go 1.13 이상의 경우 GO111MODULE이 기본값을 재정의하거나 go.mod 파일이 앱의 디렉터리에 존재하지 않는 한 App Engine은 기본적으로 module-aware 모드를 사용합니다.
종속 항목 벤더링
벤더링은 빌드 프로세스 중 소스에서 모듈을 다운로드하는 대신 앱에 사용되는 패키지를 애플리케이션 디렉터리에 복사합니다. Go는 앱의 루트 디렉터리에 있는 vendor라는 디렉터리에 앱에 필요한 패키지를 벤더링하기 위해 go build 명령어를 제공합니다.
Go 1.14 이상에서 앱의 루트 디렉터리에 vendor라는 디렉터리가 포함된 경우, go build 명령어와 App Engine 배포 프로세스는 모듈을 다운로드하는 대신 공급업체 디렉터리에 있는 패키지를 사용합니다.
Go 1.13 이하에서는 GOPATH 모드를 사용하도록 환경을 설정한 경우에만 벤더링을 사용할 수 있습니다.
비공개 종속 항목 사용
App Engine은 빌드 프로세스 중 비공개 종속 항목을 다운로드할 수 없으므로 배포 시 애플리케이션 코드에 종속 항목을 포함해야 합니다.
go.mod 파일의 replace 지시문을 사용하여 비공개 종속 항목을 선언합니다. 다음 예시에서는 앱이 /myapp/ 디렉터리에 있다고 가정합니다.
앱 디렉터리로 변경합니다.
cd/myapp
비공개 종속 항목이 포함된 디렉터리를 만듭니다.
mkdirprivate
비공개 종속 항목이 private 디렉터리에 있는지 확인합니다. 한 가지 방법은 심볼릭 링크를 만드는 것입니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[[["\u003cp\u003eGo apps in App Engine must use absolute paths in import statements, such as \u003ccode\u003eimport "github.com/example/mypackage"\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eUsing Go modules is recommended for managing dependencies, and a \u003ccode\u003ego.mod\u003c/code\u003e file should be included in the same folder as \u003ccode\u003eapp.yaml\u003c/code\u003e for dependency installation during deployment.\u003c/p\u003e\n"],["\u003cp\u003eFor Go 1.22 and later, \u003ccode\u003ego get\u003c/code\u003e cannot be used outside of a module in legacy \u003ccode\u003eGOPATH\u003c/code\u003e mode, and the use of a \u003ccode\u003ego.mod\u003c/code\u003e file for dependency management is strongly encouraged.\u003c/p\u003e\n"],["\u003cp\u003eApp Engine's build process uses the \u003ccode\u003ego build\u003c/code\u003e command, matching Go's behavior, and it prioritizes \u003ccode\u003emodule-aware\u003c/code\u003e mode if a \u003ccode\u003ego.mod\u003c/code\u003e file is present, or if using Go 1.13 or later, unless \u003ccode\u003eGO111MODULE\u003c/code\u003e dictates otherwise.\u003c/p\u003e\n"],["\u003cp\u003eVendoring, or copying packages to a \u003ccode\u003evendor\u003c/code\u003e directory in your app, is supported from Go 1.14 and above. And for the use of private dependencies, you should use a \u003ccode\u003ereplace\u003c/code\u003e directive in the \u003ccode\u003ego.mod\u003c/code\u003e file, and then place those dependencies within the \u003ccode\u003eprivate\u003c/code\u003e directory of the app.\u003c/p\u003e\n"]]],[],null,["# Specify dependencies\n\nApps that run in the Go 1.12+ standard runtime can use any\nlinux/amd64-compatible package.\n\nApp Engine requires all import statements in your Go code to\nspecify absolute paths. For example, use: \n\n import \"github.com/example/mypackage\"\n\nUse Go modules\n--------------\n\nWe recommend that you use [Go modules](https://blog.golang.org/using-go-modules)\nto manage dependencies in your Go app. You can continue to use the older `GOPATH` mode\nif you aren't ready to [migrate\nto Go modules](https://blog.golang.org/migrating-to-go-modules).\n\nStarting in Go **version 1.22 and later**:\n\n- You can't use `go get` outside of a module in the legacy `GOPATH` mode\n (`GO111MODULE`=`off`). For more information, see [Tools](https://tip.golang.org/doc/go1.22#:%7E:text=enables%20this%20feature.-,Tools,-Go%20command).\n\n- Go recommends that you use a `go.mod` file for managing dependencies. To install\n dependencies during deployment, include a `go.mod` file in the same folder as\n the `app.yaml` file. For more information about Go versions, and managing\n dependencies for vendor directories, see [`GOPATH` and Modules](https://pkg.go.dev/cmd/go#hdr-GOPATH_and_Modules).\n\nWhen you deploy your app, App Engine uses the `go build` command to\nbuild your app and matches the behavior of Go itself. To ensure that\nyour app uses `module-aware` mode, do the following in your development\nenvironment:\n\n- Create your module's `go.mod` file in the same directory as your `app.yaml`\n file. App Engine searches the current directory and the successive\n parent directories until it finds a [`go.mod` file](https://golang.org/cmd/go/#hdr-Defining_a_module).\n\n If App Engine doesn't find a `go.mod` file, it follows\n `GOPATH` mode.\n- If you set the [`GO111MODULE` environment variable](https://golang.org/ref/mod#mod-commands),\n make sure that the variable's value enables\n `module-aware` mode. When you deploy your app, App Engine checks your\n environment for `GO111MODULE` and matches the behavior of Go itself.\n App Engine only applies the `GO111MODULE` variable setting if you have\n included a `go.mod` file for your app.\n\n- For Go 1.12, don't locate your app directory within the `$GOPATH/src` folder. If\n your Go 1.12 app is anywhere in the `$GOPATH/src` directory tree,\n App Engine follows `GOPATH` mode even if you've defined a `go.mod` file\n for your app.\n\n For Go 1.13 and later, App Engine uses\n [`module-aware` mode](https://golang.org/cmd/go/#hdr-Module_support)\n by default, unless `GO111MODULE` overrides the default or a `go.mod` file\n doesn't exist in the app's directory.\n\n### Vendoring dependencies\n\n**Vendoring** copies the packages your app uses into the application directory\ninstead of downloading modules from their sources during the build process. Go\nprovides the `go build` command to\n[vendor the packages your app needs](https://golang.org/cmd/go/#hdr-Modules_and_vendoring)\ninto a directory named `vendor` in your app's root directory.\n\nIn Go 1.14 and later, if your app's root directory contains a directory named\n`vendor`, the `go build` command and the App Engine\ndeployment process use the packages in the vendor directory instead of\ndownloading modules.\n\nIn Go 1.13 and earlier, vendoring is only available if you set up your\nenvironment to use [`GOPATH` mode](https://golang.org/cmd/go/#hdr-GOPATH_and_Modules).\n\n### Use private dependencies\n\nApp Engine can't download your private dependencies during the build\nprocess, so you must include the dependencies with your application code upon\ndeployment.\n\nUse the `replace` directive in your `go.mod` file to declare\nprivate dependencies. The following example assumes your app is in the `/myapp/`\ndirectory:\n\n1. Change to your app directory:\n\n cd /myapp\n\n2. Create a directory containing your private dependencies:\n\n mkdir private\n\n Make sure your private dependency is in the `private` directory. One\n approach is by creating a symlink: \n\n mkdir private/private.example.com\n ln -s /path/to/private.example.com/foo private/private.example.com/foo\n\n3. Update your `go.mod` file to use the `replace` directive to use the `private`\n directory for your dependency:\n\n go mod edit -replace=private.example.com/foo=./private/private.example.com/foo\n\n Your `go.mod` file should now look like: \n\n ### Final `go.mod` file\n\n module private.example.com/myapp\n\n require private.example.com/foo v1.2.3\n\n replace private.example.com/foo =\u003e ./private/private.example.com/foo\n\n ### Original `go.mod` file\n\n module private.example.com/myapp\n\n require private.example.com/foo v1.2.3\n\n4. Don't modify how you import and use your private package. Your `import`\n statement should look like this:\n\n import \"private.example.com/foo\"\n\n5. Include your private dependency in your deployment by deploying your app:\n\n gcloud app deploy"]]