Skip to content

Commit 62d90e5

Browse files
committed
Fixed SubTree for multiple sub-levels
1 parent 212a84f commit 62d90e5

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

properties.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,16 @@ func (m Map) FirstLevelOf() map[string]Map {
232232
// "upload.protocol": "arduino",
233233
// "upload.maximum_size": "32256",
234234
// },
235-
func (m Map) SubTree(key string) Map {
236-
return m.FirstLevelOf()[key]
235+
func (m Map) SubTree(rootKey string) Map {
236+
rootKey += "."
237+
newMap := Map{}
238+
for key, value := range m {
239+
if !strings.HasPrefix(key, rootKey) {
240+
continue
241+
}
242+
newMap[key[len(rootKey):]] = value
243+
}
244+
return newMap
237245
}
238246

239247
// ExpandPropsInString use the Map to replace values into a format string.

0 commit comments

Comments
 (0)