func CopyFile(src, tgt string) error {
	if GetFileType(src) == folderConst {
		os.MkdirAll(tgt, os.ModePerm)
		var excludeFileList []string
		excludeFileList = append(excludeFileList, "")
		fileList := GetFileList(src, excludeFileList)
		for _, file := range fileList {
			err := CopyFile(file, filepath.Join(tgt, filepath.Base(file)))
			if err != nil {
				return err
			}
		}
	} else {
		srcFile, _ := os.Open(src)
		defer srcFile.Close()

		tgtFile, err := os.Create(tgt)
		if err != nil {
			return err
		}
		defer tgtFile.Close()

		_, err = io.Copy(tgtFile, srcFile)
		if err != nil {
			return err
		}
		tgtFile.Close()
	}
	return nil
}
// CopyFile - copies file from source location to a target location
copies file from source location to a target location
// CopyFile - copies file from source location to a target location
func CopyFile(src, tgt string) error {
	if GetFileType(src) == folderConst {
		os.MkdirAll(tgt, os.ModePerm)
		var excludeFileList []string
		excludeFileList = append(excludeFileList, "")
		fileList := GetFileList(src, excludeFileList)
		for _, file := range fileList {
			err := CopyFile(file, filepath.Join(tgt, filepath.Base(file)))
			if err != nil {
				return err
			}
		}
	} else {
		srcFile, _ := os.Open(src)
		defer srcFile.Close()
		tgtFile, err := os.Create(tgt)
		if err != nil {
			return err
		}
		defer tgtFile.Close()
		_, err = io.Copy(tgtFile, srcFile)
		if err != nil {
			return err
		}
		tgtFile.Close()
	}
	return nil
}
func CopyFile ( src , tgt string ) error { if GetFileType ( src ) == folderConst { os . MkdirAll ( tgt , os . ModePerm ) var excludeFileList [ ] string excludeFileList = append ( excludeFileList , " " ) fileList := GetFileList ( src , excludeFileList ) for _ , file := range fileList { err := CopyFile ( file , filepath . Join ( tgt , filepath . Base ( file ) ) ) if err != nil { return err } } } else { srcFile , _ := os . Open ( src ) defer srcFile . Close ( ) tgtFile , err := os . Create ( tgt ) if err != nil { return err } defer tgtFile . Close ( ) _ , err = io . Copy ( tgtFile , srcFile ) if err != nil { return err } tgtFile . Close ( ) } return nil }
copies file from source location to a target location
copies file from source location to a target location