add skip private field
This commit is contained in:
parent
43bbbb5acb
commit
b1a8bce041
5
utils.go
5
utils.go
@ -62,11 +62,16 @@ func ToMap(ss interface{}) map[string]interface{} {
|
||||
smap := make(map[string]interface{})
|
||||
mtag := regexp.MustCompile(`cc:\"(.+)\"`)
|
||||
|
||||
re := regexp.MustCompile(`^[A-Z]`)
|
||||
|
||||
for i := 0; i < t.NumField(); i++ {
|
||||
f := t.Field(i)
|
||||
tag := string(t.Type().Field(i).Tag)
|
||||
str := mtag.FindStringSubmatch(tag)
|
||||
name := t.Type().Field(i).Name
|
||||
if !re.Match([]byte(name)) {
|
||||
continue
|
||||
}
|
||||
leveling := false
|
||||
if len(str) > 1 {
|
||||
strArr := strings.Split(str[1], ",")
|
||||
|
@ -11,13 +11,14 @@ type Commands struct {
|
||||
Message string `db:"message" cc:"message"`
|
||||
Group string `db:"group" cc:"group"`
|
||||
Ctime time.Time `db:"ctime" cc:"ctime"`
|
||||
Mtime time.Time `db:"mtime" cc:"ctime"`
|
||||
Mtime time.Time `db:"mtime" cc:"mtime"`
|
||||
}
|
||||
|
||||
// CommandsWithGroup -
|
||||
type CommandsWithGroup struct {
|
||||
Commands `cc:"-,<<"`
|
||||
GroupName string `db:"group_name" cc:"group_name"`
|
||||
private string
|
||||
}
|
||||
|
||||
func TestToMap(t *testing.T) {
|
||||
@ -31,8 +32,10 @@ func TestToMap(t *testing.T) {
|
||||
cmdWGroup := CommandsWithGroup{}
|
||||
cmdWGroup.Commands = cmd
|
||||
cmdWGroup.GroupName = "asd"
|
||||
cmdWGroup.private = "123"
|
||||
|
||||
ToMap(cmdWGroup)
|
||||
m := ToMap(cmdWGroup)
|
||||
t.Log(m)
|
||||
}
|
||||
|
||||
func TestCalcPage(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user