Skip to content

Commit

Permalink
Add setting use brackets as a namespace separator
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksandr Fedorov committed Jun 28, 2021
1 parent e56bbb1 commit 91efee7
Show file tree
Hide file tree
Showing 7 changed files with 598 additions and 215 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ _testmain.go
*.test
*.prof
old.txt
new.txt
new.txt

/.idea
10 changes: 8 additions & 2 deletions decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,14 @@ func (d *decoder) traverseStruct(v reflect.Value, typ reflect.Type, namespace []
if first {
namespace = append(namespace, f.name...)
} else {
namespace = append(namespace, namespaceSeparator)
namespace = append(namespace, f.name...)
if d.d.useBrackets {
namespace = append(namespace, '[')
namespace = append(namespace, f.name...)
namespace = append(namespace, ']')
} else {
namespace = append(namespace, namespaceSeparator)
namespace = append(namespace, f.name...)
}
}

if d.setFieldByType(v.Field(f.idx), namespace, 0) {
Expand Down
Loading

0 comments on commit 91efee7

Please # to comment.