Last active
January 6, 2020 18:00
-
-
Save markito/43c6aa1a11fb79c434b7c6f3e160cc28 to your computer and use it in GitHub Desktop.
Sample Go app dealing with Cloud Events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"fmt" | |
"log" | |
cloudevents "github.com/cloudevents/sdk-go" | |
"knative.dev/eventing-contrib/pkg/kncloudevents" | |
) | |
func display(event cloudevents.Event) { | |
fmt.Printf("☁️ cloudevents.Event\n%s", event.String()) | |
} | |
func main() { | |
c, err := kncloudevents.NewDefaultClient() | |
if err != nil { | |
log.Fatal("Failed to create client, ", err) | |
} | |
log.Fatal(c.StartReceiver(context.Background(), display)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment