代码优化及错误返回改进 (#1969)

* Makefile: 使用 '?=' 替代 if-else 的判断

* 移除多余的类型转换

* 移除多余的nil判断

* map 使用简化以及错误处理优化
This commit is contained in:
Feng.YJ
2024-12-22 00:13:22 +08:00
committed by GitHub
parent 532d282509
commit 601aa6e245
5 changed files with 37 additions and 38 deletions
+7 -6
View File
@@ -3,6 +3,12 @@ package system
import (
"context"
"fmt"
"go/token"
"os"
"path/filepath"
"strings"
"text/template"
"github.com/flipped-aurora/gin-vue-admin/server/global"
common "github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
model "github.com/flipped-aurora/gin-vue-admin/server/model/system"
@@ -10,12 +16,7 @@ import (
"github.com/flipped-aurora/gin-vue-admin/server/utils"
"github.com/flipped-aurora/gin-vue-admin/server/utils/ast"
"github.com/pkg/errors"
"go/token"
"gorm.io/gorm"
"os"
"path/filepath"
"strings"
"text/template"
)
var AutoCodePackage = new(autoCodePackage)
@@ -159,7 +160,7 @@ func (s *autoCodePackage) All(ctx context.Context) (entities []model.SysAutoCode
//dir目录需要包含所有的dirNameMap
for k := 0; k < len(dir); k++ {
if dir[k].IsDir() {
if _, ok := dirNameMap[dir[k].Name()]; ok {
if ok := dirNameMap[dir[k].Name()]; ok {
delete(dirNameMap, dir[k].Name())
}
}