code: func (g *TarGzExtractor) Extract(buffer *bytes.Buffer, targetDir string) error {
  	uncompressedStream, err := gzip.NewReader(buffer)
  	if err != nil {
  		return err
  	}
  
  	tarReader := tar.NewReader(uncompressedStream)
  
  	os.MkdirAll(targetDir, 0755)
  
  	for true {
  		header, err := tarReader.Next()
  
  		if err == io.EOF {
  			break
  		}
  
  		if err != nil {
  			return err
  		}
  
  		path, err := fp.SecureJoin(targetDir, header.Name)
  		if err != nil {
  			return err
  		}
  
  		switch header.Typeflag {
  		case tar.TypeDir:
  			if err := os.Mkdir(path, 0755); err != nil {
  				return err
  			}
  		case tar.TypeReg:
  			outFile, err := os.Create(path)
  			if err != nil {
  				return err
  			}
  			if _, err := io.Copy(outFile, tarReader); err != nil {
  				outFile.Close()
  				return err
  			}
  			outFile.Close()
  		default:
  			return fmt.Errorf("unknown type: %b in %s", header.Typeflag, header.Name)
  		}
  	}
  
  	return nil
  
  }
docs: // Extract extracts compressed archives
  //
  // Implements Extractor.