示例#1
0
文件: list.go 项目: jakebailey/botzik
// 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))
	})
}
示例#2
0
文件: map.go 项目: jakebailey/botzik
// 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))
	})
}