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.
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 (
"dsBaseWeb/Utils/FileUtil"
"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 ( ) {
//遍历Controller 所有的 Go
//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 ) //创建多级目录
}
}
//遍历每一行,找到以// @X-LengthLimit开头的
//读取JSON, 如果出错, 报出行号
}