func untar(tarball, target string) error {
	reader, err := os.Open(tarball)
	if err != nil {
		return err
	}
	defer reader.Close()
	tarReader := tar.NewReader(reader)

	for {
		header, err := tarReader.Next()
		if err == io.EOF {
			break
		} else if err != nil {
			return err
		}

		path := filepath.Join(target, header.Name)
		info := header.FileInfo()
		if info.IsDir() {
			if err = os.MkdirAll(path, info.Mode()); err != nil {
				return err
			}
			continue
		}

		file, err := os.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, info.Mode())
		if err != nil {
			return err
		}
		defer file.Close()
		_, err = io.Copy(file, tarReader)
		if err != nil {
			return err
		}
	}
	return nil
}
/**
 * untars a tarbell into target directory.
 */
untars a tarbell into target directory.
/ ** * untars a tarbell into target directory . * /
func untar(tarball, target string) error {
	reader, err := os.Open(tarball)
	if err != nil {
		return err
	}
	defer reader.Close()
	tarReader := tar.NewReader(reader)
	for {
		header, err := tarReader.Next()
		if err == io.EOF {
			break
		} else if err != nil {
			return err
		}
		path := filepath.Join(target, header.Name)
		info := header.FileInfo()
		if info.IsDir() {
			if err = os.MkdirAll(path, info.Mode()); err != nil {
				return err
			}
			continue
		}
		file, err := os.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, info.Mode())
		if err != nil {
			return err
		}
		defer file.Close()
		_, err = io.Copy(file, tarReader)
		if err != nil {
			return err
		}
	}
	return nil
}
func untar ( tarball , target string ) error { reader , err := os . Open ( tarball ) if err != nil { return err } defer reader . Close ( ) tarReader := tar . NewReader ( reader ) for { header , err := tarReader . Next ( ) if err == io . EOF { break } else if err != nil { return err } path := filepath . Join ( target , header . Name ) info := header . FileInfo ( ) if info . IsDir ( ) { if err = os . MkdirAll ( path , info . Mode ( ) ) ; err != nil { return err } continue } file , err := os . OpenFile ( path , os . O_CREATE | os . O_TRUNC | os . O_WRONLY , info . Mode ( ) ) if err != nil { return err } defer file . Close ( ) _ , err = io . Copy ( file , tarReader ) if err != nil { return err } } return nil }
untars a tarbell into target directory.
untars a tarbell into target directory .