11 // GzipDecompressor is an implementation of Decompressor that can
12 // decompress gzip files.
13 type GzipDecompressor struct{}
15 func (d *GzipDecompressor) Decompress(dst, src string, dir bool) error {
16 // Directory isn't supported at all
18 return fmt.Errorf("gzip-compressed files can only unarchive to a single file")
21 // If we're going into a directory we should make that first
22 if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil {
27 f, err := os.Open(src)
33 // gzip compression is second
34 gzipR, err := gzip.NewReader(f)
41 dstF, err := os.Create(dst)
47 _, err = io.Copy(dstF, gzipR)