code: func compress(in io.Reader) (io.ReadCloser, chan struct{}) {
  	compressionDone := make(chan struct{})
  
  	pipeReader, pipeWriter := io.Pipe()
  	// Use a bufio.Writer to avoid excessive chunking in HTTP request.
  	bufWriter := bufio.NewWriterSize(pipeWriter, compressionBufSize)
  	compressor := gzip.NewWriter(bufWriter)
  
  	go func() {
  		_, err := io.Copy(compressor, in)
  		if err == nil {
  			err = compressor.Close()
  		}
  		if err == nil {
  			err = bufWriter.Flush()
  		}
  		if err != nil {
  			pipeWriter.CloseWithError(err)
  		} else {
  			pipeWriter.Close()
  		}
  		close(compressionDone)
  	}()
  
  	return pipeReader, compressionDone
  }
docs: // compress returns an io.ReadCloser which will supply a compressed version of
  // the provided Reader. The caller must close the ReadCloser after reading the
  // compressed data.
  //
  // Note that this function returns a reader instead of taking a writer as an
  // argument so that it can be used with httpBlobWriter's ReadFrom method.
  // Using httpBlobWriter's Write method would send a PATCH request for every
  // Write call.
  //
  // The second return value is a channel that gets closed when the goroutine
  // is finished. This allows the caller to make sure the goroutine finishes
  // before it releases any resources connected with the reader that was
  // passed in.