func sameFile(a, b string) (bool, error) {
	if a == b {
		return true, nil
	}
	aIno, err := inode(a)
	if err != nil {
		if os.IsNotExist(err) {
			return false, nil
		}
		return false, err
	}
	bIno, err := inode(b)
	if err != nil {
		if os.IsNotExist(err) {
			return false, nil
		}
		return false, err
	}
	if aIno > 0 && aIno == bIno {
		return true, nil
	}
	return false, nil
}
sameFile tried to determine if to paths are the same file.
If the paths don't match, we lookup the inode on supported systems.
package configload
import (
	"io"
	"os"
	"path/filepath"
)
func copyDir(dst, src string) error {
	src, err := filepath.EvalSymlinks(src)
	if err != nil {
		return err
	}
	walkFn := func(path string, info os.FileInfo, err error) error {
		if err != nil {
			return err
		}
		if path == src {
			return nil
		}
		dstPath := filepath.Join(dst, path[len(src):])
		if eq, err := sameFile(path, dstPath); eq {
			return nil
		} else if err != nil {
			return err
		}
		if info.IsDir() {
			if path == filepath.Join(src, dst) {
				return nil
			}
			if err := os.MkdirAll(dstPath, 0755); err != nil {
				return err
			}
			return nil
		}
		if info.Mode()&os.ModeSymlink == os.ModeSymlink {
			target, err := os.Readlink(path)
			if err != nil {
				return err
			}
			return os.Symlink(target, dstPath)
		}
		srcF, err := os.Open(path)
		if err != nil {
			return err
		}
		defer srcF.Close()
		dstF, err := os.Create(dstPath)
		if err != nil {
			return err
		}
		defer dstF.Close()
		if _, err := io.Copy(dstF, srcF); err != nil {
			return err
		}
		return os.Chmod(dstPath, info.Mode())
	}
	return filepath.Walk(src, walkFn)
}