Skip to content

Commit

Permalink
Add GetDefaultPath
Browse files Browse the repository at this point in the history
  • Loading branch information
goldspy98 authored Feb 22, 2017
1 parent 22139eb commit 5d9715d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,15 @@ func (t *TomlTree) GetDefault(key string, def interface{}) interface{} {
return val
}

// GetDefaultPath works like GetPath but with a default value
func (t *TomlTree) GetDefaultPath(keys []string, def interface{}) interface{} {
val := t.GetPath(keys)
if val == nil {
return def
}
return val
}

// Set an element in the tree.
// Key is a dot-separated path (e.g. a.b.c).
// Creates all necessary intermediates trees, if needed.
Expand Down

0 comments on commit 5d9715d

Please sign in to comment.