mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-03 04:10:25 +08:00
导出API列表时对数据进行排序,以保证每次输出的稳定性
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -111,6 +112,9 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
// 排序以保证输出内容的稳定性
|
||||
sort.Strings(rootDirs)
|
||||
|
||||
for _, rootDir := range rootDirs {
|
||||
files, err := filepath.Glob(rootDir + "/service_*.go")
|
||||
if err != nil {
|
||||
@@ -118,6 +122,9 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
// 排序以保证输出内容的稳定性
|
||||
sort.Strings(files)
|
||||
|
||||
var methodNameReg = regexp.MustCompile(`func\s*\(\w+\s+\*\s*(\w+Service)\)\s*(\w+)\s*\(`) // $1: serviceName, $2 methodName
|
||||
for _, file := range files {
|
||||
data, err := os.ReadFile(file)
|
||||
@@ -234,6 +241,9 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
// 排序以保持稳定性
|
||||
sort.Strings(files)
|
||||
|
||||
for _, path := range files {
|
||||
func(path string) {
|
||||
var filename = filepath.Base(path)
|
||||
@@ -385,6 +395,9 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
// 排序以保持稳定性
|
||||
sort.Strings(files)
|
||||
|
||||
for _, path := range files {
|
||||
func(path string) {
|
||||
var name = strings.TrimSuffix(filepath.Base(path), ".md")
|
||||
@@ -404,6 +417,11 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
// 对消息进行排序,以保持稳定性
|
||||
sort.Slice(messages, func(i, j int) bool {
|
||||
return messages[i].Name < messages[j].Name
|
||||
})
|
||||
|
||||
var rpcList = &RPCList{
|
||||
Services: services,
|
||||
Messages: messages,
|
||||
|
||||
Reference in New Issue
Block a user