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