NewWriter creates a new Writer. Writes to the returned Writer are compressed and written to w.
package main import ( "bytes" "compress/zlib" "fmt" ) func main() { var b bytes.Buffer w := zlib.NewWriter(&b) w.Write([]byte("hello, world\n")) w.Close() fmt.Println(b.Bytes()) }