File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ func (autoApi *AutoCodeApi) PreviewTemp(c *gin.Context) {
38
38
response .FailWithMessage (err .Error (), c )
39
39
return
40
40
}
41
-
41
+ a . KeyWord () // 处理go关键字
42
42
a .PackageT = caser .String (a .Package )
43
43
autoCode , err := autoCodeService .PreviewTemp (a )
44
44
if err != nil {
@@ -65,6 +65,7 @@ func (autoApi *AutoCodeApi) CreateTemp(c *gin.Context) {
65
65
response .FailWithMessage (err .Error (), c )
66
66
return
67
67
}
68
+ a .KeyWord () // 处理go关键字
68
69
var apiIds []uint
69
70
if a .AutoCreateApiToSql {
70
71
if ids , err := autoCodeService .AutoCreateApi (& a ); err != nil {
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package system
3
3
import (
4
4
"errors"
5
5
"github.com/flipped-aurora/gin-vue-admin/server/global"
6
+ "go/token"
6
7
)
7
8
8
9
// AutoCodeStruct 初始版本自动化代码工具
@@ -21,6 +22,14 @@ type AutoCodeStruct struct {
21
22
PackageT string `json:"-"`
22
23
}
23
24
25
+ // KeyWord 是go关键字的处理加上 _ ,防止编译报错
26
+ // Author [SliverHorn](https://github.com/SliverHorn)
27
+ func (a * AutoCodeStruct ) KeyWord () {
28
+ if token .IsKeyword (a .Abbreviation ) {
29
+ a .Abbreviation = "_" + a .Abbreviation
30
+ }
31
+ }
32
+
24
33
type Field struct {
25
34
FieldName string `json:"fieldName"` // Field名
26
35
FieldDesc string `json:"fieldDesc"` // 中文名
You can’t perform that action at this time.
0 commit comments