title: What does net/context's cancel() function do?
body: <p><a href="https://godoc.org/golang.org/x/net/context" rel="nofollow">net/context</a>'s <code>WithDeadline()</code> and <code>WithTimeout()</code> functions both return a <code>cancel</code> function, which docs say to always call with a defer, such as:</p>
  
  <pre><code>func slowOperationWithTimeout(ctx context.Context) (Result, error) {
      ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond)
      defer cancel()  // releases resources if slowOperation completes before timeout elapses
  </code></pre>
  
  <p>But what "resources" are actually being released in this function?</p>