Search⌘ K
AI Features

Using context as a Key/Value Store

Explore how to use Go's context package as a key value store in concurrent programming. Understand passing values with context.WithValue, retrieving them, and the role of context.TODO in creating contexts for operations.

Passing values in a context

In this lesson, we pass values in a Context and use it as a key-value store. In this case, we do not pass values into contexts in order to provide further information about why they were canceled. The keyVal.go program illustrates the use of the context.TODO() function, as well as the use of the ...