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

github.com/googleapis/google-cloudevents-go

CloudEvent Types for Go

by googleapis

v0.2.0 (see all)License:Apache-2.0
go get github.com/googleapis/google-cloudevents-go
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
  • Enum support

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.

GitHub Stars

12

LAST COMMIT

7mos ago

MAINTAINERS

0

CONTRIBUTORS

13

OPEN ISSUES

0

OPEN PRs

0
VersionTagPublished
v0.2.0
7mos ago
v0.1.1
8mos ago
v0.1.1-0.20210701184830-d6f26947d5f9
1yr ago
v0.1.1-0.20210701004623-c7d106f97425
1yr ago
No alternatives found
No tutorials found
Add a tutorial