github.com/rck/u-root@v0.0.0-20180106144920-7eb602e381bb/pkg/gzip/gunzip.go (about) 1 package gzip 2 3 import ( 4 "io" 5 6 "github.com/klauspost/pgzip" 7 ) 8 9 // Decompress takes gzip compressed input from io.Reader and expands it using pgzip 10 // to io.Writer. Data is read in blocksize (KB) chunks using upto the number of 11 // CPU cores specified. 12 func Decompress(r io.Reader, w io.Writer, blocksize int, processes int) error { 13 zr, err := pgzip.NewReaderN(r, blocksize*1024, processes) 14 if err != nil { 15 return err 16 } 17 18 if _, err := io.Copy(w, zr); err != nil { 19 zr.Close() 20 return err 21 } 22 23 return zr.Close() 24 }