Google CloudEvents - Go

GoDoc unstable

This library provides Go types for Google CloudEvent data.


  • Simple import and interface
  • Inline documentation for Go structs
  • 64 bit number parsing
  • Automatic decoding of base64 data


Note: This library requires Go 1.11+.

To install this package, run:

go get -u

Example Usage

Example event of type MessagePublishedData from Cloud Pub/Sub.

package main

import (


func main() {
	data := []byte(`{
    "message": {
      "attributes": {
        "key": "value"
      "data": "SGVsbG8sIFdvcmxkIQ==",
      "messageId": "136969346945"
    "subscription": "projects/myproject/subscriptions/mysubscription"

	var e pubsub.MessagePublishedData
	err := json.Unmarshal(data, &e)
	if err != nil {
	fmt.Printf("%+s\n", e.Message.Data) // Hello, World!

More detailed documentation about the usage of every type can be found in this library's reference.


The file has detailed examples for how to use every event data type.