-
Notifications
You must be signed in to change notification settings - Fork 10
Fix GoLang errors in readme #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
afrittoli
merged 5 commits into
cdevents:main
from
bradmccoydev:chore/34/fix-errors-in-readme
Nov 10, 2022
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
25e17b3
chore: fix error in readme for sending as cloudevent
bradmccoydev 6c0d49d
chore: fix readme golang code
bradmccoydev bb404a6
chore: add cdevents import to cloudevent example
bradmccoydev 9fd7a3c
chore: rename module to modules
bradmccoydev 77d7379
chore: replace tabs for spaces in readme
bradmccoydev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,20 +50,31 @@ func main() { | |
|
|
||
| ## Send your first CDEvent as CloudEvent | ||
|
|
||
| Import the module in your code | ||
|
|
||
| ```golang | ||
| import cloudevents "github.com/cloudevents/sdk-go/v2" | ||
| ``` | ||
|
|
||
| To send a CDEvent as CloudEvent: | ||
|
|
||
| ```golang | ||
| func main() { | ||
| // (...) set the event first | ||
| ce := cdevents.AsCloudEvent(event) | ||
| ce, err := cdevents.AsCloudEvent(event) | ||
|
|
||
| // Set send options | ||
| ctx := cloudevents.ContextWithTarget(context.Background(), "http://localhost:8080/") | ||
| ctx = cloudevents.WithEncodingBinary(ctx) | ||
|
|
||
| // Sent the CloudEvent | ||
| c, err := cloudevents.NewClientHTTP() | ||
| if err != nil { | ||
| log.Fatalf("failed to create client, %v", err) | ||
| } | ||
|
||
|
|
||
| // Send the CloudEvent | ||
| // c is a CloudEvent client | ||
| if result := c.Send(ctx, ce); cloudevents.IsUndelivered(result) { | ||
| if result := c.Send(ctx, *ce); cloudevents.IsUndelivered(result) { | ||
| log.Fatalf("failed to send, %v", result) | ||
| } | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.