Go 1.11 telah mencapai akhir dukungan
dan akan dihentikan penggunaannya
pada 31 Januari 2026. Setelah penghentian penggunaan, Anda tidak akan dapat men-deploy aplikasi Go 1.11, meskipun organisasi Anda sebelumnya menggunakan kebijakan organisasi untuk mengaktifkan kembali deployment runtime lama. Aplikasi Go 1.11 yang ada akan terus berjalan dan menerima traffic setelah tanggal penghentiannya. Sebaiknya Anda bermigrasi ke Go versi terbaru yang didukung.
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Aplikasi yang berjalan dalam runtime standar Go 1.11 dapat menggunakan
paket apa pun yang kompatibel dengan linux/amd64.
Menggunakan modul Go
Sebaiknya gunakan modul Go
untuk mengelola dependensi dalam aplikasi Go Anda, tetapi
Anda dapat terus menggunakan mode GOPATH yang lebih lama jika belum siap untuk bermigrasi
ke modul Go.
Saat Anda men-deploy aplikasi, App Engine menggunakan perintah go build untuk
membangun aplikasi sehingga sesuai dengan perilaku Go itu sendiri. Untuk memastikan bahwa
aplikasi Anda menggunakan mode sadar modul, lakukan hal-hal berikut di lingkungan
pengembangan:
Buat file go.mod modul Anda di dalam direktori yang sama dengan file app.yaml
Anda. App Engine menelusuri direktori saat ini, lalu beberapa
direktori induk berurutan hingga menemukan file go.mod.
Jika App Engine tidak menemukan file go.mod, maka App Engine akan mengikuti
mode GOPATH.
Jika Anda menyetel variabel lingkungan GO111MODULE,
pastikan nilai variabel mengaktifkan
mode sadar modul. Saat Anda men-deploy aplikasi, App Engine akan memeriksa
lingkungan Anda untuk menemukan GO111MODULE dan mencocokkan perilaku Go itu sendiri.
App Engine hanya menerapkan setelan variabel GO111MODULE jika Anda telah
menyertakan file go.mod untuk aplikasi Anda.
Jangan tempatkan direktori aplikasi Anda di dalam atau di bawah $GOPATH/src. Jika aplikasi Anda
berada di mana saja dalam hierarki direktori $GOPATH/src, App Engine akan mengikuti
mode GOPATH meskipun Anda telah menentukan file go.mod untuk aplikasi Anda.
Menggunakan dependensi pribadi
App Engine tidak dapat mendownload dependensi pribadi Anda selama proses
build, sehingga Anda harus menyertakannya bersama kode aplikasi setelah deployment.
Anda harus menggunakan perintah replace dalam file go.mod untuk mendeklarasikan
dependensi pribadi. Contoh berikut mengasumsikan bahwa aplikasi Anda berada di direktori
/myapp/:
Ubah ke direktori aplikasi Anda:
cd /myapp
Buat direktori yang berisi dependensi pribadi Anda:
mkdir private
Pastikan dependensi pribadi Anda berada di direktori private. Salah satu
pendekatannya adalah dengan membuat symlink:
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-19 UTC."],[[["\u003cp\u003eApps in the Go 1.11 standard runtime can utilize any linux/amd64-compatible package, but all import statements must use absolute paths.\u003c/p\u003e\n"],["\u003cp\u003eGo modules are recommended for dependency management, but older GOPATH mode is still supported if you are not ready to migrate.\u003c/p\u003e\n"],["\u003cp\u003eApp Engine uses the \u003ccode\u003ego build\u003c/code\u003e command, and to ensure module-aware mode, you should create a \u003ccode\u003ego.mod\u003c/code\u003e file in the same directory as your \u003ccode\u003eapp.yaml\u003c/code\u003e file or a parent directory.\u003c/p\u003e\n"],["\u003cp\u003eIf using the \u003ccode\u003eGO111MODULE\u003c/code\u003e environment variable, ensure its value enables module-aware mode, and it will only be applied if a \u003ccode\u003ego.mod\u003c/code\u003e file exists.\u003c/p\u003e\n"],["\u003cp\u003ePrivate dependencies must be included with your application code upon deployment, and you must utilize the \u003ccode\u003ereplace\u003c/code\u003e directive in your \u003ccode\u003ego.mod\u003c/code\u003e file to point to the local directory containing them.\u003c/p\u003e\n"]]],[],null,["# Specifying Dependencies\n\n\u003cbr /\u003e\n\nApps that run in the Go 1.11 standard runtime can use any\nlinux/amd64-compatible package.\n| **Important:** App Engine requires all import statements in your Go code to specify absolute paths. For example, use: \n|\n| ```\n| import \"github.com/example/mypackage\"\n| ```\n\nUsing 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, but\nyou can continue to use the older GOPATH mode if you aren't ready to [migrate\nto Go modules](https://blog.golang.org/migrating-to-go-modules).\n\nWhen you deploy your app, App Engine uses the `go build` command to\nbuild your app and therefore 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, then 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 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\u003c!-- --\u003e\n\n- Do not locate your app directory in or below `$GOPATH/src`. If your app is anywhere in the `$GOPATH/src` directory tree, App Engine follows GOPATH mode even if you've defined a `go.mod` file for your app.\n\n### Using private dependencies\n\nApp Engine cannot download your private dependencies during the build\nprocess, so you must include them with your application code upon deployment.\n\nYou will need to use 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. Do not modify how you import and use your private package. Your `import`\n statement should look like:\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\n\n\u003cbr /\u003e"]]