Skip to content
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

_content/blog: cross-reference context articles #299

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions _content/blog/context-and-structs.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,7 @@ Context makes it easy to propagate important cross-library and cross-API informa
When passed as the first argument in a method rather than stored in a struct type, users can take full advantage of its extensibility in order to build a powerful tree of cancellation, deadline, and metadata information through the call stack. And, best of all, its scope is clearly understood when it's passed in as an argument, leading to clear comprehension and debuggability up and down the stack.

When designing an API with context, remember the advice: pass `context.Context` in as an argument; don't store it in structs.

## Further reading

- [Go Concurrency Patterns: Context (2014 blog post)](context.md)
5 changes: 5 additions & 0 deletions _content/blog/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,8 @@ Their client libraries would then accept a `Context` from the calling code.
By establishing a common interface for request-scoped data and cancellation,
`Context` makes it easier for package developers to share code for creating
scalable services.

## Further reading

- [Go Concurrency Patterns: Pipelines and cancellation (2014 blog post)](pipelines.md)
- [Contexts and structs (2021 blog post)](context-and-structs.md)