Google Cloud Function tutorial and hacks to enable the use of Go.
Switch branches/tags
Nothing to show
Clone or download
Latest commit bd4c804 Apr 11, 2017
Failed to load latest commit information.
event use map not string Apr 10, 2017
examples update docs Apr 10, 2017
shim use detailed event types Apr 10, 2017
LICENSE add LICENSE Nov 26, 2016 add Disclaimer Apr 10, 2017
build search path for shim binary Apr 9, 2017
main.go add bucket example Apr 10, 2017

Google Cloud Functions Go

This project contains a collection of tutorials and hacks for using Go with Google Cloud Functions.


This is not an official Google product (experimental or otherwise), it is just code that happens to be owned by Google.

How it Works

Google Cloud Functions only supports node.js so shims must be used to wrap calls to Go code. The cloud-functions-go-shim binary bridges node.js and Go functions. Each Go function to be executed must be exported from a Go plugin.

The use of Go plugins limit the runtime environment to Linux.


Download the cloud-functions-go and cloud-functions-go-shim binaries and put them in your path.



Create a Go plugin holding the function to be executed:

go build -buildmode=plugin -o examples/topic/main.go


Use the cloud-functions-go-shim to test your function:

cat examples/topic/event.json | \
  cloud-functions-go-shim -entry-point F -event-type topic -plugin-path 

Testing only works on Linux; a current limitation of Go plugins.


The cloud-functions-go command is used to package your function along with the necessary shims for execution in the Cloud Functions environment.

cloud-functions-go -entry-point F -event-type topic -plugin-path



The zip archive containes the following files:

  • index.js - node.js shim that calls out to the cloud-functions-go-shim binary
  • - the Go function to be executed
  • cloud-functions-go-shim - the shim between node.js and Go


Upload the zip archive and set the function to F and the trigger to topic.