-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for named pointers to structs
This makes it possible to use named struct pointers like this: type Document struct { Title string Owner *User `db:"owner"` Author *User `db:"author"` }
- Loading branch information
Showing
3 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -337,7 +337,7 @@ func getMapping(t reflect.Type, tagName string, mapFunc, tagMapFunc func(string) | |
fi.Index = apnd(tq.fi.Index, fieldPos) | ||
fi.Children = make([]*FieldInfo, Deref(f.Type).NumField()) | ||
queue = append(queue, typeQueue{Deref(f.Type), &fi, pp}) | ||
} else if fi.Zero.Kind() == reflect.Struct { | ||
} else if fi.Zero.Kind() == reflect.Struct || (fi.Zero.Kind() == reflect.Ptr && fi.Zero.Type().Elem().Kind() == reflect.Struct) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Pitmairen
Author
Contributor
|
||
fi.Index = apnd(tq.fi.Index, fieldPos) | ||
fi.Children = make([]*FieldInfo, Deref(f.Type).NumField()) | ||
queue = append(queue, typeQueue{Deref(f.Type), &fi, fi.Path}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This line creates an endless loop for me, and consumes up to 3GM memory, maybe because the struct embeds itself