title: How can I use gzip on a string?
body: <p>I want to use Go to read out a chunk from a file, treat it as a <code>string</code> and <code>gzip</code> this chunk. I know how to read from the file and treat it as a <code>string</code>, but when it comes to <code>compress/gzip</code> I am lost.</p>
  
  <p>Should I create an <code>io.writer</code>, which writes to a <code>buf</code> (byte slice), use <code>gzip.NewWriter(io.writer)</code> to get a <code>w *gzip.Writer</code> and then use <code>w.Write(chunk_of_file)</code> to write the chunk of file to <code>buf</code>? Then I would need to treat the string as a byte slice.</p>