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-04(UTC)"],[],[],null,["# Specify dependencies in Go\n\nYou can specify your Cloud Run function dependencies with\neither a [Go Module](https://golang.org/doc/go1.11#modules) or a `vendor`\ndirectory.\n\nSpecify dependencies with Go modules\n------------------------------------\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](https://github.com/GoogleCloudPlatform/functions-framework-go)\nis a required dependency for all functions. Although\nCloud Run functions installs it on your behalf when the function\nis created, we recommend that you include it as an explicit dependency for\nclarity.\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\nSpecify dependencies with a `vendor` directory\n----------------------------------------------\n\nCloud Run functions also lets you include your dependencies with a\n[`vendor` directory](https://golang.org/cmd/go/#hdr-Vendor_Directories).\nUsing a vendor directory is helpful if your dependency is not available through 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 policy for [supporting existing deployments](/functions/docs/concepts/go-runtime#go_116_public_preview) for functions based on a version earlier than 1.16.\n\nUse private dependencies\n------------------------\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 preceding instructions to avoid potential conflicts between the\n`go.mod` file and the `vendor` directory."]]