Skip to content

Commit

Permalink
_content/blog: cross-reference context articles
Browse files Browse the repository at this point in the history
This change cross-references the context.md and context-and-structs.md
articles with each other with the addition of the conventional
"Further reading" sections. The context-and-structs.md article has
been somewhat of a singleton article without being referenced from the
other one, and it would be worth providing a hair more exposure given
the subtleties of the API.

Change-Id: Ifadcf6ec3f9cc47fff1e63f6841b7705fd018a4f
GitHub-Last-Rev: 7361271
GitHub-Pull-Request: #299
Reviewed-on: https://go-review.googlesource.com/c/website/+/616495
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
  • Loading branch information
matttproud authored and gopherbot committed Oct 1, 2024
1 parent fa72e5e commit 2c92ff8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
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)

0 comments on commit 2c92ff8

Please sign in to comment.