You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.7 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package main
import (
"dsBaseRpc/Utils/CommonUtil"
"dsBaseRpc/Utils/FileUtil"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
)
var protoFiles []string
/**
功能:递归一个目录下的所有文件
作者:黄海
时间2020-05-20
*/
func GetProtoFiles(folder string) {
files, _ := ioutil.ReadDir(folder)
for _, file := range files {
if file.IsDir() {
GetProtoFiles(folder + "/" + file.Name())
} else {
if strings.HasSuffix(file.Name(), ".pb.go") || strings.HasSuffix(file.Name(), ".proto") {
protoFiles = append(protoFiles, folder+"/"+file.Name())
}
}
}
}
func main() {
//1、先把本地的代码提交
_=CommonUtil.Exec("git", "add","-A",".")
_=CommonUtil.Exec("git", "commit","-am","'commit'")
//2、执行一下git pull + git fetch
_=CommonUtil.Exec("git", "pull")
_=CommonUtil.Exec("git", "fetch")
//3、完成合并后执行一次推送
_=CommonUtil.Exec("git", "push","origin","master")
fmt.Println("成功更新dsMin项目可以直接使用最新的proto文件了")
//4、源目录
sourcePath := "../dsBaseWeb/Business"
//5、目标目录
targetPath := "./RpcService"
//6、递归获取所有的pb.go文件
GetProtoFiles(sourcePath)
//7、遍历所有的文件
for i := range protoFiles {
//映射的目标文件
tPath := targetPath + strings.Replace(protoFiles[i], sourcePath, "", -1)
paths, _ := filepath.Split(tPath)
//判断目录是不是存在
if !FileUtil.PathExists(paths) {
_=os.MkdirAll(paths, os.ModePerm) //创建多级目录
}
//拷贝
_=FileUtil.CopyFile(protoFiles[i], tPath)
}
fmt.Printf("恭喜,所有文件成功复制!共复制文件:%d个\n", len(protoFiles))
}