优化代码

This commit is contained in:
GoEdgeLab
2022-08-04 11:24:50 +08:00
parent 13c4e9271f
commit 9fbcc8dca1
2 changed files with 2965 additions and 3165 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -10,7 +10,7 @@ import (
"github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/Tea"
_ "github.com/iwind/TeaGo/bootstrap" _ "github.com/iwind/TeaGo/bootstrap"
"github.com/iwind/TeaGo/types" "github.com/iwind/TeaGo/types"
"io/ioutil" "os"
"path/filepath" "path/filepath"
"regexp" "regexp"
"strings" "strings"
@@ -91,7 +91,12 @@ func main() {
for _, path := range files { for _, path := range files {
func(path string) { func(path string) {
data, err := ioutil.ReadFile(path) var filename = filepath.Base(path)
if filename == "service_authority_key.proto" || filename == "service_authority_node.proto" {
return
}
data, err := os.ReadFile(path)
if err != nil { if err != nil {
fmt.Println("[ERROR]" + err.Error()) fmt.Println("[ERROR]" + err.Error())
return return
@@ -142,7 +147,7 @@ func main() {
services = append(services, &ServiceInfo{ services = append(services, &ServiceInfo{
Name: serviceName, Name: serviceName,
Methods: methods, Methods: methods,
Filename: filepath.Base(path), Filename: filename,
Doc: comment, Doc: comment,
}) })
} }
@@ -231,7 +236,7 @@ func main() {
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")
data, err := ioutil.ReadFile(path) data, err := os.ReadFile(path)
if err != nil { if err != nil {
fmt.Println("[ERROR]read '" + path + "' failed: " + err.Error()) fmt.Println("[ERROR]read '" + path + "' failed: " + err.Error())
return return
@@ -259,7 +264,7 @@ func main() {
} }
var jsonFile = Tea.Root + "/rpc.json" var jsonFile = Tea.Root + "/rpc.json"
err = ioutil.WriteFile(jsonFile, jsonData, 0666) err = os.WriteFile(jsonFile, jsonData, 0666)
if err != nil { if err != nil {
fmt.Println("[ERROR]write json to file failed: " + err.Error()) fmt.Println("[ERROR]write json to file failed: " + err.Error())
return return