* refactor(tools ): refactor cod

Improve code readability and performance

* fix(tools ): fix len bug

Co-authored-by: ksco <hyang@33.cn>
This commit is contained in:
_ksco
2021-08-11 17:33:18 +08:00
committed by GitHub
parent e024aebb66
commit cc264dcf55
4 changed files with 13 additions and 19 deletions

View File

@@ -64,7 +64,7 @@ func (p parser) convert2Spec() error {
}
func (p parser) fillInfo() {
properties := make(map[string]string, 0)
properties := make(map[string]string)
if p.ast.Info != nil {
p.spec.Info = spec.Info{}
for _, kv := range p.ast.Info.Kvs {
@@ -258,7 +258,7 @@ func (p parser) fillService() error {
route.ResponseType = p.astTypeToSpec(astRoute.Route.Reply.Name)
}
if astRoute.AtDoc != nil {
properties := make(map[string]string, 0)
properties := make(map[string]string)
for _, kv := range astRoute.AtDoc.Kv {
properties[kv.Key.Text()] = kv.Value.Text()
}
@@ -290,7 +290,7 @@ func (p parser) fillService() error {
func (p parser) fillRouteAtServer(astRoute *ast.ServiceRoute, route *spec.Route) error {
if astRoute.AtServer != nil {
properties := make(map[string]string, 0)
properties := make(map[string]string)
for _, kv := range astRoute.AtServer.Kv {
properties[kv.Key.Text()] = kv.Value.Text()
}
@@ -314,7 +314,7 @@ func (p parser) fillRouteAtServer(astRoute *ast.ServiceRoute, route *spec.Route)
func (p parser) fillAtServer(item *ast.Service, group *spec.Group) {
if item.AtServer != nil {
properties := make(map[string]string, 0)
properties := make(map[string]string)
for _, kv := range item.AtServer.Kv {
properties[kv.Key.Text()] = kv.Value.Text()
}