code: func (h *ArchiveHandler) newArchiveToGuest(u *url.URL) (File, error) {
  	r, w := io.Pipe()
  
  	buf := bufio.NewReader(r)
  
  	a := &archive{
  		name:   u.Path,
  		Reader: buf,
  		Writer: w,
  	}
  
  	var cerr error
  	var wg sync.WaitGroup
  
  	a.done = func() error {
  		_ = w.Close()
  		// We need to wait for unpack to finish to complete its work
  		// and to propagate the error if any to Close.
  		wg.Wait()
  		return cerr
  	}
  
  	wg.Add(1)
  	go func() {
  		defer wg.Done()
  
  		c := func() error {
  			// Drain the pipe of tar trailer data (two null blocks)
  			if cerr == nil {
  				_, _ = io.Copy(ioutil.Discard, a.Reader)
  			}
  			return nil
  		}
  
  		header, _ := buf.Peek(len(gzipHeader))
  
  		if bytes.Equal(header, gzipHeader) {
  			gz, err := gzip.NewReader(a.Reader)
  			if err != nil {
  				_ = r.CloseWithError(err)
  				cerr = err
  				return
  			}
  
  			c = gz.Close
  			a.Reader = gz
  		}
  
  		tr := tar.NewReader(a.Reader)
  
  		cerr = h.Read(u, tr)
  
  		_ = c()
  		_ = r.CloseWithError(cerr)
  	}()
  
  	return a, nil
  }
docs: // newArchiveToGuest returns an hgfs.File implementation to expand a gzip'd tar into a directory.