code: func extractTar(r io.Reader, dir string) error {
  	first := true // true if we are on the first entry of tarball
  	tr := tar.NewReader(r)
  	for {
  		hdr, err := tr.Next()
  		if err == io.EOF {
  			// end of tar archive
  			break
  		}
  		if err != nil {
  			return err
  		}
  
  		// Check if the same kite version is installed before
  		if first {
  			first = false
  			kiteName := strings.TrimSuffix(hdr.Name, ".kite/")
  
  			installed, err := isInstalled(kiteName)
  			if err != nil {
  				return err
  			}
  
  			if installed {
  				return fmt.Errorf("Already installed: %s", kiteName)
  			}
  		}
  
  		path := filepath.Join(dir, hdr.Name)
  
  		if hdr.FileInfo().IsDir() {
  			os.MkdirAll(path, 0700)
  		} else {
  			mode := 0600
  			if isBinaryFile(hdr.Name) {
  				mode = 0700
  			}
  
  			f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.FileMode(mode))
  			if err != nil {
  				return err
  			}
  
  			if _, err := io.Copy(f, tr); err != nil {
  				return err
  			}
  		}
  	}
  	return nil
  }
docs: // extractTar reads from the io.Reader and writes the files into the directory.