mirror of
https://github.com/hanzoai/sqlbuilder.git
synced 2026-10-01 00:37:42 +00:00
ignore unexported fields that are not embedded structs
This commit is contained in:
+5
-4
@@ -12,10 +12,11 @@ import (
|
||||
)
|
||||
|
||||
type structUserForTest struct {
|
||||
ID int `db:"id" fieldtag:"important"`
|
||||
Name string `fieldtag:"important"`
|
||||
Status int `db:"status" fieldtag:"important"`
|
||||
CreatedAt int `db:"created_at"`
|
||||
ID int `db:"id" fieldtag:"important"`
|
||||
Name string `fieldtag:"important"`
|
||||
Status int `db:"status" fieldtag:"important"`
|
||||
CreatedAt int `db:"created_at"`
|
||||
unexported struct{}
|
||||
}
|
||||
|
||||
var userForTest = NewStruct(new(structUserForTest))
|
||||
|
||||
@@ -51,6 +51,11 @@ func (sf *structFields) parse(t reflect.Type, mapper FieldMapperFunc, prefix str
|
||||
for i := 0; i < l; i++ {
|
||||
field := t.Field(i)
|
||||
|
||||
// Skip unexported fields that are not embedded structs.
|
||||
if !field.IsExported() && !field.Anonymous {
|
||||
continue
|
||||
}
|
||||
|
||||
if field.Anonymous {
|
||||
ft := field.Type
|
||||
|
||||
|
||||
Reference in New Issue
Block a user