golang-glide在win10下出现“Unable to export dependencies to vendor directory: Error moving files”错误解决

找到gopath:下 文件github.com\Masterminds\glide\path\winbug.go
修改如下函数:

func CustomRename(o, n string) error {
 
	// Handking windows cases first
	if runtime.GOOS == "windows" {
		msg.Debug("Detected Windows. Moving files using windows command")  
		//cmd := exec.Command("cmd.exe", "/c", "move", o, n)  //将这一行代码注释掉
		cmd := exec.Command("cmd.exe", "/c", "xcopy /s/y", o, n+"\\") //新增这一行代码
		output, err := cmd.CombinedOutput()
		//fmt.Println("CustomRename:",output,err)
		if err != nil {
			return fmt.Errorf("Error moving files: %s. output: %s", err, output)
		}
 
		return nil
	} else if detectWsl() {
		cmd := exec.Command("mv", o, n)
		output, err2 := cmd.CombinedOutput()
		msg.Debug("Detected Windows Subsystem for Linux. Removing files using subsystem command")
		if err2 != nil {
			return fmt.Errorf("Error moving files: %s. output: %s", err2, output)
		}
 
		return nil
	}
 
	return os.Rename(o, n)
}

修改完后,编译成glide.exe,并放到环境变量路径下[$gopath/bin]。。

你可能感兴趣的:(go)