Skip to content

Commit 6c594fb

Browse files
authored
Merge pull request #2 from thedadams/handle-ptr-to-strct
fix: allow pointers to structs to propagate arguments
2 parents 34f690b + 6107882 commit 6c594fb

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
### Go template
2+
# If you prefer the allow list template instead of the deny list, see community template:
3+
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
4+
#
5+
# Binaries for programs and plugins
6+
*.exe
7+
*.exe~
8+
*.dll
9+
*.so
10+
*.dylib
11+
12+
# Test binary, built with `go test -c`
13+
*.test
14+
15+
# Output of the go coverage tool, specifically when used with LiteIDE
16+
*.out
17+
18+
# Go workspace file
19+
go.work
20+
21+
.idea/
22+
.vscode/
23+

builder.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@ func fields(obj any) []fieldInfo {
4848

4949
for i := 0; i < objValue.NumField(); i++ {
5050
fieldType := objValue.Type().Field(i)
51-
if fieldType.Anonymous && fieldType.Type.Kind() == reflect.Struct {
52-
result = append(result, fields(objValue.Field(i).Addr().Interface())...)
51+
if fieldType.Anonymous {
52+
if fieldType.Type.Kind() == reflect.Struct {
53+
result = append(result, fields(objValue.Field(i).Addr().Interface())...)
54+
} else if fieldType.Type.Kind() == reflect.Ptr && fieldType.Type.Elem().Kind() == reflect.Struct {
55+
result = append(result, fields(objValue.Field(i).Interface())...)
56+
}
5357
} else if !fieldType.Anonymous {
5458
result = append(result, fieldInfo{
5559
FieldValue: objValue.Field(i),

0 commit comments

Comments
 (0)