func UnTar(dest string, r io.Reader, compressed bool) (err error) {
	if compressed {
		gzr, err := gzip.NewReader(r)
		if err != nil {
			return err
		}
		defer gzr.Close()
		r = gzr
	}
	tr := tar.NewReader(r)
	for {
		header, err := tr.Next()
		switch {
		case err == io.EOF:
			return nil
		case err != nil:
			return err
		case header == nil:
			continue
		}
		target := filepath.Join(dest, header.Name)
		switch header.Typeflag {
		case tar.TypeDir:
			if _, err := os.Stat(target); err != nil {
				if err := os.MkdirAll(target, 0755); err != nil {
					return err
				}
			}
		case tar.TypeReg:
			f, err := os.OpenFile(target, os.O_CREATE|os.O_RDWR, os.FileMode(header.Mode))
			if err != nil {
				return err
			}
			if _, err := io.CopyBuffer(f, tr, nil); err != nil {
				return err
			}
			f.Close()
		}
	}
}
UnTar untars a tar or tgz file into the dest folder.
dest is the folder location
io.Reader is a reader that is tar (or compressed tar) format
compressed is true if reader is a compressed format
package file
import (
	"archive/tar"
	"compress/gzip"
	"io"
	"os"
	"path/filepath"
)
func UntarInPlace(path string) error {
	folder := TrimExt(path)
	file, err := os.Open(path)
	if err != nil {
		return err
	}
	defer file.Close()
	compressed := filepath.Ext(path) == ".tgz"
	return UnTar(folder, file, compressed)
}