The Daily Go
338 subscribers
53 photos
2 videos
3 files
657 links
We provide you daily Golang contents. If you want to post any content contact with us.
.
Administrators:
👉🏻@aidenzibaei
👉🏻@amin_khozaei

#jaryan904259
Download Telegram
The Daily Go
The Daily Go How to correctly use context in Golang https://medium.com/@cep21/how-to-correctly-use-context-context-in-go-1-7-8f2c0fafdf39 #Guide #Concurrency
Introduction to context :

In #Go_servers, each incoming request is handled in its own goroutine. Request handlers often start additional goroutines to access backends such as databases and RPC services. The set of goroutines working on a request typically needs access to request-specific values such as the identity of the end user, authorization tokens, and the request's deadline. When a request is canceled or times out, all the goroutines working on that request should exit quickly so the system can reclaim any resources they are using.

At #Google, we developed a context package that makes it easy to pass request-scoped values, cancelation signals, and deadlines across API boundaries to all the goroutines involved in handling a request. The package is publicly available as context. This article describes how to use the package and provides a complete working example.

https://blog.golang.org/context