修复从API代码中提取角色时无法查找子目录的Bug

This commit is contained in:
GoEdgeLab
2022-08-23 21:55:59 +08:00
parent b814aaaef6
commit 6e63889b5a
2 changed files with 4123 additions and 3734 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -9,6 +9,7 @@ import (
"fmt"
"github.com/iwind/TeaGo/Tea"
_ "github.com/iwind/TeaGo/bootstrap"
"github.com/iwind/TeaGo/logs"
"github.com/iwind/TeaGo/types"
"os"
"path/filepath"
@@ -96,6 +97,21 @@ func main() {
var methodRolesMap = map[string][]string{} // method => roles
{
var rootDir = filepath.Clean(Tea.Root + "/../../EdgeAPI/internal/rpc/services")
entries, err := os.ReadDir(rootDir)
if err != nil {
logs.Println("[ERROR]read api services from '" + rootDir + "' failed: " + err.Error())
return
}
var rootDirs = []string{rootDir}
for _, entry := range entries {
if entry.IsDir() {
rootDirs = append(rootDirs, rootDir+string(os.PathSeparator)+entry.Name())
}
}
for _, rootDir := range rootDirs {
files, err := filepath.Glob(rootDir + "/service_*.go")
if err != nil {
fmt.Println("[ERROR]list service implementation files failed: " + err.Error())
@@ -178,6 +194,7 @@ func main() {
}
}
}
}
var services = []*ServiceInfo{}
var messages = []*MessageInfo{}