Example #1
0
// ForEach runs a function for each function in the list.
func (l List) ForEach(fn func(int, string) error) error {
	return helpers.ForEachWrap(l.b, func(key, value []byte) error {
		if bytes.Equal(key, lengthKey) {
			return nil
		}
		i, err := strconv.Atoi(string(key))
		if err != nil {
			return err
		}
		return fn(i, string(value))
	})
}
Example #2
0
// ForEach runs a function over the map.
func (m Map) ForEach(fn func(string, string) error) error {
	return helpers.ForEachWrap(m.b, func(key, value []byte) error {
		return fn(string(key), string(value))
	})
}