func copyDirectory(src string, dst string) error {
	var err error
	var fds []os.FileInfo
	var srcinfo os.FileInfo

	if srcinfo, err = os.Stat(src); err != nil {
		return err
	}

	if err = os.MkdirAll(dst, srcinfo.Mode()); err != nil {
		return err
	}

	if fds, err = ioutil.ReadDir(src); err != nil {
		return err
	}
	for _, fd := range fds {
		srcfp := path.Join(src, fd.Name())
		dstfp := path.Join(dst, fd.Name())

		if fd.IsDir() {
			if err = copyDirectory(srcfp, dstfp); err != nil {
				fmt.Println(err)
			}
		} else {
			if err = copyFile(srcfp, dstfp); err != nil {
				fmt.Println(err)
			}
		}
	}
	return nil
}
// copyDirectory copies a whole directory recursively, taking care of creating the destiny directory if does not exist
copyDirectory copies a whole directory recursively, taking care of creating the destiny directory if does not exist
// copyDirectory copies a whole directory recursively taking care of creating the destiny directory if does not exist
func copyDirectory(src string, dst string) error {
	var err error
	var fds []os.FileInfo
	var srcinfo os.FileInfo
	if srcinfo, err = os.Stat(src); err != nil {
		return err
	}
	if err = os.MkdirAll(dst, srcinfo.Mode()); err != nil {
		return err
	}
	if fds, err = ioutil.ReadDir(src); err != nil {
		return err
	}
	for _, fd := range fds {
		srcfp := path.Join(src, fd.Name())
		dstfp := path.Join(dst, fd.Name())
		if fd.IsDir() {
			if err = copyDirectory(srcfp, dstfp); err != nil {
				fmt.Println(err)
			}
		} else {
			if err = copyFile(srcfp, dstfp); err != nil {
				fmt.Println(err)
			}
		}
	}
	return nil
}
func copyDirectory ( src string , dst string ) error { var err error var fds [ ] os . FileInfo var srcinfo os . FileInfo if srcinfo , err = os . Stat ( src ) ; err != nil { return err } if err = os . MkdirAll ( dst , srcinfo . Mode ( ) ) ; err != nil { return err } if fds , err = ioutil . ReadDir ( src ) ; err != nil { return err } for _ , fd := range fds { srcfp := path . Join ( src , fd . Name ( ) ) dstfp := path . Join ( dst , fd . Name ( ) ) if fd . IsDir ( ) { if err = copyDirectory ( srcfp , dstfp ) ; err != nil { fmt . Println ( err ) } } else { if err = copyFile ( srcfp , dstfp ) ; err != nil { fmt . Println ( err ) } } } return nil }
copyDirectory copies a whole directory recursively, taking care of creating the destiny directory if does not exist
copyDirectory copies a whole directory recursively taking care of creating the destiny directory if does not exist