code: func CopyDir(src string, dst string) (err error) {
  	src = filepath.Clean(src)
  	dst = filepath.Clean(dst)
  
  	si, err := os.Stat(src)
  	if err != nil {
  		return err
  	}
  	if !si.IsDir() {
  		return fmt.Errorf("source is not a directory")
  	}
  
  	_, err = os.Stat(dst)
  	if err != nil && !os.IsNotExist(err) {
  		return
  	}
  	if err == nil {
  		return fmt.Errorf("destination already exists")
  	}
  
  	err = os.MkdirAll(dst, si.Mode())
  	if err != nil {
  		return
  	}
  
  	entries, err := ioutil.ReadDir(src)
  	if err != nil {
  		return
  	}
  
  	for _, entry := range entries {
  		srcPath := filepath.Join(src, entry.Name())
  		dstPath := filepath.Join(dst, entry.Name())
  
  		// If the entry is a symlink, we copy the contents
  		for entry.Mode()&os.ModeSymlink != 0 {
  			target, err := os.Readlink(srcPath)
  			if err != nil {
  				return err
  			}
  
  			entry, err = os.Stat(target)
  			if err != nil {
  				return err
  			}
  		}
  
  		if entry.IsDir() {
  			err = CopyDir(srcPath, dstPath)
  			if err != nil {
  				return
  			}
  		} else {
  			err = CopyFile(srcPath, dstPath)
  			if err != nil {
  				return
  			}
  		}
  	}
  
  	return
  }
docs: // CopyDir recursively copies a directory tree, attempting to preserve permissions.
  // Source directory must exist, destination directory must *not* exist.
  // Symlinks are ignored and skipped.