GitRoot
Craft your forge, Build your project, Grow your community freely
1// SPDX-FileCopyrightText: 2026 Romain Maneschi <romain@gitroot.dev>
2//
3// SPDX-License-Identifier: EUPL-1.2
4
5package iterator
6
7import "encoding/json"
8
9type pullIterator struct {
10 slice []any
11 index int
12}
13
14func NewPullIterator(slice []any) *pullIterator {
15 return &pullIterator{
16 slice: slice,
17 index: 0,
18 }
19}
20
21func (it *pullIterator) Next() (string, bool) {
22 if it.index >= len(it.slice) {
23 return "", false
24 }
25
26 val := it.slice[it.index]
27 valJson, err := json.Marshal(val)
28 if err != nil {
29
30 }
31 it.index++
32 return string(valJson), true
33}
34
35func (it *pullIterator) Reset() {
36 it.index = 0
37}