google-cloudevents-go

module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2021 License: Apache-2.0

README

Google CloudEvents - Go

GoDoc unstable

This library provides Go types for Google CloudEvent data.

Features

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

Installation

Note: This library requires Go 1.11+.

To install this package, run:

go get -u github.com/googleapis/google-cloudevents-go

Example Usage

Example event of type MessagePublishedData from Cloud Pub/Sub.

package main

import (
	"encoding/json"
	"fmt"

	"github.com/googleapis/google-cloudevents-go/cloud/pubsub/v1"
)

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 {
		panic(err)
	}
	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.

Reference

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

Directories

Path Synopsis
cloud
firebase
generators

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL