Deploy your Go app to Google Cloud Functions by building a binary, creating a deployment configuration, and running the deploy command.
-
Build your Go binary for the target architecture.
GOOS=linux GOARCH=amd64 go build -o main main.go -
Create a
cloudbuild.yamlfile to define the build and deployment steps. `echo 'steps:
- name: "gcr.io/cloud-builders/gcloud" args: ["functions", "deploy", "my-function", "--runtime", "go121", "--entry-point", "HelloWorld", "--trigger-http"]' > cloudbuild.yaml`
-
Deploy the function using the Cloud Build service.
gcloud builds submit --config=cloudbuild.yaml -
Verify the deployment status in the Google Cloud Console.
gcloud functions describe my-function --region us-central1