fix: 代码生成器 结构体简称发生的关键字冲突 #1089

This commit is contained in:
SliverHorn
2022-05-27 13:50:27 +08:00
parent 95fd9f92cd
commit 0eae201401
2 changed files with 11 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ package system
import (
"errors"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"go/token"
)
// AutoCodeStruct 初始版本自动化代码工具
@@ -21,6 +22,14 @@ type AutoCodeStruct struct {
PackageT string `json:"-"`
}
// KeyWord 是go关键字的处理加上 _ ,防止编译报错
// Author [SliverHorn](https://github.com/SliverHorn)
func (a *AutoCodeStruct) KeyWord() {
if token.IsKeyword(a.Abbreviation) {
a.Abbreviation = "_" + a.Abbreviation
}
}
type Field struct {
FieldName string `json:"fieldName"` // Field名
FieldDesc string `json:"fieldDesc"` // 中文名