~nilium/go-ini

f4ad7eecbf72d3a012b4baa95d28db8e6814c7ff — Noel Cower 8 years ago dec51fa
Add WithPrefix method to Values

Convenience function for looking up all keys with a prefix, since
that's a useful case.

Change-Id: I272f4d967f30801659a97f247bd277f757dc990d
1 files changed, 6 insertions(+), 0 deletions(-)

M ini.go
M ini.go => ini.go +6 -0
@@ 88,6 88,12 @@ func (v Values) Matching(dst Values, fn func(string, []string) bool) Values {
	return dst
}

func (v Values) WithPrefix(dst Values, prefix string) Values {
	return v.Matching(dst, func(k string, _ []string) bool {
		return strings.HasPrefix(k, prefix)
	})
}

// nextfunc is a parsing function that modifies the decoder's state and returns another parsing
// function. If nextfunc returns io.EOF, parsing is complete. Any other error halts parsing.
type nextfunc func() (nextfunc, error)