예제 #1
0
func copyToRepos() (err error) {
	var (
		dirName, dirPath, srcDirPath string
		fileInfos                    []os.FileInfo
	)
	for _, repoBaseDirPath := range []string{"D:\\github", "C:\\gitrepos"} {
		if fileInfos, _ = ioutil.ReadDir(repoBaseDirPath); len(fileInfos) > 0 {
			for _, fi := range fileInfos {
				if dirName = fi.Name(); fi.IsDir() {
					for _, githubName := range subDirs {
						if srcDirPath = ugo.GopathSrcGithub(githubName, dirName); ufs.DirExists(srcDirPath) {
							break
						}
					}
					if dirPath = filepath.Join(repoBaseDirPath, dirName); ufs.DirExists(srcDirPath) {
						wg.Add(1)
						go func(dirPath, srcDirPath string) {
							defer wg.Done()
							var err error
							if err = ufs.ClearDirectory(dirPath, ".git"); err == nil {
								err = ufs.CopyAll(srcDirPath, dirPath, &dirTmpSkipper)
							}
							if err != nil {
								log.Printf("Error @ %s:\t%+v", dirPath, err)
							}
						}(dirPath, srcDirPath)
					}
				}
			}
		}
	}
	return
}
예제 #2
0
func copyToDropbox() (err error) {
	const dbp = "Dropbox/_gd"
	for _, dropDirPath := range []string{filepath.Join("D:", dbp), filepath.Join(ugo.UserHomeDirPath(), dbp)} {
		if ufs.DirExists(dropDirPath) {
			if err = ufs.ClearDirectory(dropDirPath); err == nil {
				for _, githubName := range subDirs {
					wg.Add(1)
					go func(dropDirPath, githubName string) {
						defer wg.Done()
						dst := filepath.Join(dropDirPath, githubName)
						if err := ufs.CopyAll(ugo.GopathSrcGithub(githubName), dst, &dirTmpSkipper); err != nil {
							log.Printf("Error @ %s:\t%+v", dst, err)
						}
					}(dropDirPath, githubName)
				}
			}
			break
		}
	}
	return
}