[ Web Proxy ]
URL:
Viewing: https://cloud.google.com/docs/buildpacks/go [Back]  [Original]

Building a Go application  |  Buildpacks  |  Google Cloud Documentation Skip to main content
Google Cloud Documentation [Google Cloud Documentation]
Send feedback

Building a Go application Stay organized with collections Save and categorize content based on your preferences.

Specifying the Go Version

By default the Go buildpack uses the latest stable version of the Go compiler. If your application requires a specific version, you can use the GOOGLE_GO_VERSION environment variable to provide a semver constraint that will be used to select an available Go version.

pack build sample-go --builder=gcr.io/buildpacks/builder \
  --env GOOGLE_GO_VERSION="17.x.x"

Compilation Flags

The Go buildpack compiles your application source into an executable using the go build command. The following environment variables can be used to configure the build behavior:

Managing Dependencies

We recommend that you use Go modules to manage dependencies in your Go app. The Go buildpack uses the go build command to build your app and therefore matches the behavior of Go itself. To ensure that your app uses module-aware mode, you should include a go.mod file in your application root.

Vendoring dependencies

Vendoring copies the packages your app uses into the application directory instead of downloading modules from their sources during the build process. Go provides the go build command to vendor the packages your app needs into a directory named vendor in your app's root directory.

Configure the Application Entrypoint

By default, the Go buildpack will configure the application container entry invoke the main executable produced when compiling your application source. If you need to override this, you can do so by providing a Procfile or passing the GOOGLE_ENTRYPOINT environment variable.

Environment Variables

The Go buildpack supports the following environment variables to customize your container

GO

See Go documentation on Environment Variables

Example: GOFLAGS=-flag=value passes -flag=value to go commands.

Send feedback

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-08-11 UTC.

Need to tell us more? [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-08-11 UTC."],[],[]]

Web Proxy Viewer  |  New URL  |  Original Page