{"id":13493259,"url":"https://github.com/cloudevents/sdk-go","last_synced_at":"2025-05-11T13:59:26.070Z","repository":{"id":38274557,"uuid":"138634880","full_name":"cloudevents/sdk-go","owner":"cloudevents","description":"Go SDK for CloudEvents","archived":false,"fork":false,"pushed_at":"2025-05-08T14:07:25.000Z","size":4524,"stargazers_count":875,"open_issues_count":121,"forks_count":228,"subscribers_count":28,"default_branch":"main","last_synced_at":"2025-05-11T13:59:14.633Z","etag":null,"topics":["cncf"],"latest_commit_sha":null,"homepage":"https://cloudevents.github.io/sdk-go/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloudevents.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-06-25T18:31:51.000Z","updated_at":"2025-05-09T11:04:44.000Z","dependencies_parsed_at":"2023-12-17T10:24:33.110Z","dependency_job_id":"1ea0d66d-af7c-4f13-92d7-5cf7d25aaf28","html_url":"https://github.com/cloudevents/sdk-go","commit_stats":{"total_commits":694,"total_committers":128,"mean_commits":5.421875,"dds":0.8443804034582132,"last_synced_commit":"cbba3fd04ad2dc4dcea59f0b02174d117b9e746a"},"previous_names":["dispatchframework/cloudevents-go-sdk"],"tags_count":258,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudevents%2Fsdk-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudevents%2Fsdk-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudevents%2Fsdk-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudevents%2Fsdk-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloudevents","download_url":"https://codeload.github.com/cloudevents/sdk-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253576264,"owners_count":21930169,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cncf"],"created_at":"2024-07-31T19:01:13.606Z","updated_at":"2025-05-11T13:59:26.044Z","avatar_url":"https://github.com/cloudevents.png","language":"Go","funding_links":[],"categories":["Go","cncf"],"sub_categories":[],"readme":"# Go SDK for [CloudEvents](https://github.com/cloudevents/spec)\n\n[![go-doc](https://godoc.org/github.com/cloudevents/sdk-go?status.svg)](https://godoc.org/github.com/cloudevents/sdk-go)\n[![Go Report Card](https://goreportcard.com/badge/github.com/cloudevents/sdk-go)](https://goreportcard.com/report/github.com/cloudevents/sdk-go)\n[![Releases](https://img.shields.io/github/release-pre/cloudevents/sdk-go.svg)](https://github.com/cloudevents/sdk-go/releases)\n[![LICENSE](https://img.shields.io/github/license/cloudevents/sdk-go.svg)](https://github.com/cloudevents/sdk-go/blob/main/LICENSE)\n\nOfficial CloudEvents SDK to integrate your application with CloudEvents.\n\nThis library will help you to:\n\n- Represent CloudEvents in memory\n- Use\n  [Event Formats](https://github.com/cloudevents/spec/blob/v1.0/spec.md#event-format)\n  to serialize/deserialize CloudEvents\n- Use\n  [Protocol Bindings](https://github.com/cloudevents/spec/blob/v1.0/spec.md#protocol-binding)\n  to send/receive CloudEvents\n\n_Note:_ Supported\n[CloudEvents specification](https://github.com/cloudevents/spec): 0.3, 1.0\n\n_Note:_ Tested and supported go version(s): 1.23+\n\n## Get started\n\nAdd the module as dependency to your project:\n\n```console\ngo get github.com/cloudevents/sdk-go/v2\n```\n\nAnd import the module in your code\n\n```go\nimport cloudevents \"github.com/cloudevents/sdk-go/v2\"\n```\n\n## Send your first CloudEvent\n\nTo send a CloudEvent using HTTP:\n\n```go\nfunc main() {\n\tc, err := cloudevents.NewClientHTTP()\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create client, %v\", err)\n\t}\n\n\t// Create an Event.\n\tevent :=  cloudevents.NewEvent()\n\tevent.SetSource(\"example/uri\")\n\tevent.SetType(\"example.type\")\n\tevent.SetData(cloudevents.ApplicationJSON, map[string]string{\"hello\": \"world\"})\n\n\t// Set a target.\n\tctx := cloudevents.ContextWithTarget(context.Background(), \"http://localhost:8080/\")\n\n\t// Send that Event.\n\tif result := c.Send(ctx, event); cloudevents.IsUndelivered(result) {\n\t\tlog.Fatalf(\"failed to send, %v\", result)\n\t} else {\n\t\tlog.Printf(\"sent: %v\", event)\n\t\tlog.Printf(\"result: %v\", result)\n\t}\n}\n```\n\n## Receive your first CloudEvent\n\nTo start receiving CloudEvents using HTTP:\n\n```go\nfunc receive(event cloudevents.Event) {\n\t// do something with event.\n    fmt.Printf(\"%s\", event)\n}\n\nfunc main() {\n\t// The default client is HTTP.\n\tc, err := cloudevents.NewClientHTTP()\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create client, %v\", err)\n\t}\n\tif err = c.StartReceiver(context.Background(), receive); err != nil {\n\t\tlog.Fatalf(\"failed to start receiver: %v\", err)\n\t}\n}\n```\n\n## Create a CloudEvent from an HTTP Request\n\n```go\nfunc handler(w http.ResponseWriter, r *http.Request) {\n\tevent, err := cloudevents.NewEventFromHTTPRequest(r)\n\tif err != nil {\n\t\tlog.Printf(\"failed to parse CloudEvent from request: %v\", err)\n\t\thttp.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)\n\t}\n\tw.Write([]byte(event.String()))\n\tlog.Println(event.String())\n}\n```\n\n## Serialize/Deserialize a CloudEvent\n\nTo marshal a CloudEvent into JSON:\n\n```go\nevent := cloudevents.NewEvent()\nevent.SetID(\"example-uuid-32943bac6fea\")\nevent.SetSource(\"example/uri\")\nevent.SetType(\"example.type\")\nevent.SetData(cloudevents.ApplicationJSON, map[string]string{\"hello\": \"world\"})\n\nbytes, err := json.Marshal(event)\n```\n\nTo unmarshal JSON back into a CloudEvent:\n\n```go\nevent :=  cloudevents.NewEvent()\n\nerr := json.Unmarshal(bytes, \u0026event)\n```\n\n## Go further\n\n- Look at the complete documentation: https://cloudevents.github.io/sdk-go/\n- Dig into the godoc: https://godoc.org/github.com/cloudevents/sdk-go/v2\n- Check out the [samples directory](./samples) for an extended list of examples\n  showing the different SDK features\n\n## Community\n\n- There are bi-weekly calls immediately following the\n  [Serverless/CloudEvents call](https://github.com/cloudevents/spec#meeting-time)\n  at 9am PT (US Pacific). Which means they will typically start at 10am PT, but\n  if the other call ends early then the SDK call will start early as well. See\n  the\n  [CloudEvents meeting minutes](https://docs.google.com/document/d/1OVF68rpuPK5shIHILK9JOqlZBbfe91RNzQ7u_P7YCDE/edit#)\n  to determine which week will have the call.\n- Slack: #cloudeventssdk channel under\n  [CNCF's Slack workspace](https://slack.cncf.io/).\n- Email: https://lists.cncf.io/g/cncf-cloudevents-sdk\n\nEach SDK may have its own unique processes, tooling and guidelines, common\ngovernance related material can be found in the\n[CloudEvents `community`](https://github.com/cloudevents/spec/tree/master/community)\ndirectory. In particular, in there you will find information concerning how SDK\nprojects are\n[managed](https://github.com/cloudevents/spec/blob/master/community/SDK-GOVERNANCE.md),\n[guidelines](https://github.com/cloudevents/spec/blob/master/community/SDK-maintainer-guidelines.md)\nfor how PR reviews and approval, and our\n[Code of Conduct](https://github.com/cloudevents/spec/blob/master/community/GOVERNANCE.md#additional-information)\ninformation.\n\nIf there is a security concern with one of the CloudEvents specifications, or\nwith one of the project's SDKs, please send an email to\n[cncf-cloudevents-security@lists.cncf.io](mailto:cncf-cloudevents-security@lists.cncf.io).\n\n## Additional SDK Resources\n\n- [List of current active maintainers](MAINTAINERS.md)\n- [How to contribute to the project](CONTRIBUTING.md)\n- [SDK's License](LICENSE)\n- [SDK's Release process](RELEASING.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudevents%2Fsdk-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloudevents%2Fsdk-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudevents%2Fsdk-go/lists"}