Go 버전이 1.16 이전의 경우 go.mod 파일 및 vendor 디렉터리가 있으면 함수를 배포할 때 vendor 디렉터리가 무시됩니다.
vendor 디렉터리가 보장되도록 하려면 .gcloudignore 파일을 사용하여 go.mod 및 go.sum 파일을 업로드하지 않도록 합니다.
프로젝트 디렉터리의 루트에 다음 내용이 포함된 .gcloudignore 파일을 만듭니다.
go.mod
go.sum
# Also ignore Git directories. Delete the following two lines if you want to
# upload them.
.git
.gitignore
비공개 종속 항목 사용
함수의 종속 항목이 공개 액세스가 불가능한 저장소에 호스팅된 경우 vendor 디렉터리를 사용하여 종속 항목을 가져온 후 함수를 배포해야 합니다. go.mod 파일을 사용하려는 경우 위의 안내를 참조하여 go.mod 파일과 vendor 디렉터리의 잠재적 충돌을 방지하세요.
[[["이해하기 쉬움","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-03(UTC)"],[[["\u003cp\u003eCloud Run functions allow dependencies to be specified using either a \u003ccode\u003ego.mod\u003c/code\u003e file (Go Modules) or a \u003ccode\u003evendor\u003c/code\u003e directory.\u003c/p\u003e\n"],["\u003cp\u003eUsing Go Modules, dependencies listed in the \u003ccode\u003ego.mod\u003c/code\u003e file are automatically incorporated upon function deployment.\u003c/p\u003e\n"],["\u003cp\u003eThe Functions Framework is a required dependency, and it is recommended to explicitly include it for clarity, even though Cloud Run installs it automatically.\u003c/p\u003e\n"],["\u003cp\u003eA \u003ccode\u003evendor\u003c/code\u003e directory is useful when dependencies are not accessible via a dependency manager or when internet access is restricted.\u003c/p\u003e\n"],["\u003cp\u003eFor Go versions earlier than 1.16, a \u003ccode\u003e.gcloudignore\u003c/code\u003e file should be used to avoid uploading \u003ccode\u003ego.mod\u003c/code\u003e and \u003ccode\u003ego.sum\u003c/code\u003e files to ensure the \u003ccode\u003evendor\u003c/code\u003e directory is used.\u003c/p\u003e\n"]]],[],null,["# Specify dependencies in Go\n==========================\n\nYou can specify your Cloud Run function dependencies with either a\n[Go Module](https://golang.org/doc/go1.11#modules) or a `vendor` directory.\n\n### Specify dependencies with Go modules\n\nTo specify Cloud Run functions dependencies with a Go Module,\nyou list them in a `go.mod` file.\nWhen you deploy your function, Go automatically incorporates the dependencies in\nyour `go.mod` file.\n\nTo create a `go.mod` file, see\n[Managing dependencies in Go](https://go.dev/doc/modules/managing-dependencies).\n\nThe [Functions Framework](/functions/docs/functions-framework) is a\nrequired dependency for all functions. Although Cloud Run functions\ninstalls it on your behalf when the function is created, we recommend\nthat you include it as an explicit dependency for clarity.\n\nIf your\nfunction relies on private dependencies, we recommend that you\nmirror `functions-framework` to your private registry. Include the mirrored\n`functions-framework` as a dependency to your function to avoid installing the\npackage from the public internet.\n\n### Specify dependencies with a `vendor` directory\n\nCloud Run functions also lets you include your dependencies via a\n[`vendor` directory](https://golang.org/cmd/go/#hdr-Vendor_Directories).\nUsing a vendor directory is helpful if your dependency is not available via a\ndependency manager or if your Cloud Run functions environment's internet\naccess is restricted.\n\nMost of the time, `vendor` directories are maintained with a dependency manager.\nYou can use any dependency manager you like. For example, you can use Go's\nModules functionality to create a `vendor` directory from your `go.mod` file.\n\nYou must include the [Functions Framework for Go](https://github.com/GoogleCloudPlatform/functions-framework-go) in your vendor\ndirectory. To use the Go toolchain to do this:\n\n1. Add the following directive to the import block of your Go code:\n\n _ \"github.com/GoogleCloudPlatform/functions-framework-go/funcframework\"\n\n2. Update your `go.mod` file to include the new imported package:\n\n go mod tidy\n\n3. Create a `vendor` directory using the contents of your `go.mod` file:\n\n go mod vendor\n\n#### Go versions earlier than 1.16\n\nFor versions of Go earlier than 1.16, if you have a `go.mod` file and a `vendor`\ndirectory, the `vendor` directory will be ignored when you deploy your function.\nTo ensure that your vendor directory is respected, use a\n[`.gcloudignore`](/sdk/gcloud/reference/topic/gcloudignore) file\nto avoid uploading your `go.mod` and `go.sum` files:\n\n1. Create a `.gcloudignore` file at the root of your project directory with the\n following contents:\n\n ```sh\n go.mod\n go.sum\n\n # Also ignore Git directories. Delete the following two lines if you want to\n # upload them.\n .git\n .gitignore\n ```\n\n| **Note:** Learn more about Cloud Run functions policy for [supporting existing deployments](/functions/1stgendocs/concepts/go-runtime#go_116_public_preview) for functions based on a version earlier than 1.16.\n\n### Using private dependencies\n\nIf your function's dependencies are hosted in a repository that is not\npublicly accessible, you must use a `vendor` directory to fetch your\ndependencies before deploying your function. If you plan to use a `go.mod`\nfile, see the instructions above to avoid potential conflicts between the\n`go.mod` file and the `vendor` directory."]]