code: func extractFileFromTar(tr *tar.Reader, file string) ([]byte, error) {
  	for {
  		hdr, err := tr.Next()
  		switch err {
  		case io.EOF:
  			return nil, fmt.Errorf("file not found")
  		case nil:
  			if filepath.Clean(hdr.Name) != filepath.Clean(file) {
  				continue
  			}
  			switch hdr.Typeflag {
  			case tar.TypeReg:
  			case tar.TypeRegA:
  			default:
  				return nil, fmt.Errorf("requested file not a regular file")
  			}
  			buf, err := ioutil.ReadAll(tr)
  			if err != nil {
  				return nil, err
  			}
  			return buf, nil
  		default:
  			return nil, err
  		}
  	}
  }
docs: // extractFileFromTar extracts a regular file from the given tar, returning its
  // contents as a byte slice