This library provides Go types for Google CloudEvent data.
Note: This library requires Go 1.11+.
To install this package, run:
go get -u github.com/googleapis/google-cloudevents-go
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.
The reference.md
file has detailed examples for how to use every event data type.
Version | Tag | Published |
---|---|---|
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 |