feat:filter_test_suffix

This commit is contained in:
songzhibin97
2022-07-07 19:10:10 +08:00
parent 4bf872d292
commit 89746b3338
2 changed files with 16 additions and 2 deletions
+14
View File
@@ -4,6 +4,7 @@ import (
"errors"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"go/token"
"strings"
)
// AutoCodeStruct 初始版本自动化代码工具
@@ -23,6 +24,11 @@ type AutoCodeStruct struct {
PackageT string `json:"-"`
}
func (a *AutoCodeStruct) Pretreatment() {
a.KeyWord()
a.SuffixTest()
}
// KeyWord 是go关键字的处理加上 _ ,防止编译报错
// Author [SliverHorn](https://github.com/SliverHorn)
func (a *AutoCodeStruct) KeyWord() {
@@ -31,6 +37,14 @@ func (a *AutoCodeStruct) KeyWord() {
}
}
// SuffixTest 处理_test 后缀
// Author [SliverHorn](https://github.com/SliverHorn)
func (a *AutoCodeStruct) SuffixTest() {
if strings.HasSuffix(a.Package, "test") {
a.Package = a.Package + "_"
}
}
type Field struct {
FieldName string `json:"fieldName"` // Field名
FieldDesc string `json:"fieldDesc"` // 中文名