Need help with sdk-go?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

454 Stars 141 Forks Apache License 2.0 588 Commits 62 Opened issues


Go SDK for CloudEvents

Services available


Need anything else?

Contributors list

Go SDK for CloudEvents

go-doc Go Report Card Releases LICENSE

Official CloudEvents SDK to integrate your application with CloudEvents.

This library will help you to:

Note: Supported CloudEvents specification: 0.3, 1.0

Note: Supported go version: 1.14+

Get started

Add the module as dependency using go mod:

go get[email protected]

And import the module in your code

import cloudevents ""

Send your first CloudEvent

To send a CloudEvent using HTTP:

func main() {
    c, err := cloudevents.NewClientHTTP()
    if err != nil {
        log.Fatalf("failed to create client, %v", err)

// Create an Event.
event :=  cloudevents.NewEvent()
event.SetData(cloudevents.ApplicationJSON, map[string]string{"hello": "world"})

// Set a target.
ctx := cloudevents.ContextWithTarget(context.Background(), "http://localhost:8080/")

// Send that Event.
if result := c.Send(ctx, event); cloudevents.IsUndelivered(result) {
    log.Fatalf("failed to send, %v", result)


Receive your first CloudEvent

To start receiving CloudEvents using HTTP:

func receive(event cloudevents.Event) {
    // do something with event.
    fmt.Printf("%s", event)

func main() { // The default client is HTTP. c, err := cloudevents.NewClientHTTP() if err != nil { log.Fatalf("failed to create client, %v", err) } log.Fatal(c.StartReceiver(context.Background(), receive)); }

Serialize/Deserialize a CloudEvent

To marshal a CloudEvent into JSON:

event := cloudevents.NewEvent()
event.SetData(cloudevents.ApplicationJSON, map[string]string{"hello": "world"})

bytes, err := json.Marshal(event)

To unmarshal JSON back into a CloudEvent:

event :=  cloudevents.NewEvent()

err := json.Unmarshal(bytes, &event)

Go further

  • Look at the complete documentation:
  • Dig into the godoc:
  • Check out the samples directory for an extended list of examples showing the different SDK features


  • There are bi-weekly calls immediately following the Serverless/CloudEvents call at 9am PT (US Pacific). Which means they will typically start at 10am PT, but if the other call ends early then the SDK call will start early as well. See the CloudEvents meeting minutes to determine which week will have the call.
  • Slack: #cloudeventssdk channel under CNCF's Slack workspace.
  • Email:
  • Contact for additional information: Scott Nichols (
    @Scott Nichols
    on slack).

Each SDK may have its own unique processes, tooling and guidelines, common governance related material can be found in the CloudEvents

directory. In particular, in there you will find information concerning how SDK projects are managed, guidelines for how PR reviews and approval, and our Code of Conduct information.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.