# How To Use Contexts in Go ![rw-book-cover](https://community-cdn-digitalocean-com.global.ssl.fastly.net/rdy4YmqgHCKE2BTGp6VR96rk) ## Metadata - Author: [[Kristin Davidson]] - Full Title: How To Use Contexts in Go - Category: #articles - Summary: This tutorial teaches you how to use Go's context package to manage and signal the completion of processes in your programs. You learn to create contexts, add values, and automatically cancel them using methods like context.WithCancel, context.WithDeadline, and context.WithTimeout. The goal is to make your programs more efficient by stopping unnecessary processing when a context is done. - URL: https://www.digitalocean.com/community/tutorials/how-to-use-contexts-in-go ## Highlights - When developing a large application, especially in server software, sometimes it’s helpful for a function to know more about the environment it’s being executed in aside from the information needed for a function to work on its own. ([View Highlight](https://read.readwise.io/read/01k2q7ms02sq4qvg4y8m0zmvgm)) - For example, if a web server function is handling an HTTP request for a specific client, the function may only need to know which URL the client is requesting to serve the response. The function might only take that URL as a parameter. However, things can always happen when serving a response, such as the client disconnecting before receiving the response. If the function serving the response doesn’t know the client disconnected, the server software may end up spending more computing time than it needs calculating a response that will never be used. ([View Highlight](https://read.readwise.io/read/01k2q7nvxkc9gcvkt8fbfdy2ky)) - his saves valuable compute resources on a busy server and frees them up to handle another client’s request. ([View Highlight](https://read.readwise.io/read/01k2q7pgvm29p6xxqjpnqnejn9)) - By using the `context.Context` interface in the `context` package and passing it from function to function, programs can convey that information from the beginning function of a program, such as `main`, all the way to the deepest function call in the program. ([View Highlight](https://read.readwise.io/read/01k2q7s9cyqa0pry2r4fwswmzz))