Files
script/input_mem.go
Dmitry Fedotov 454c632462 feat: revise API, add README.md, LICENSE (#2)
Co-authored-by: Dmitry Fedotov <dmitry@uint32.ru>
Co-committed-by: Dmitry Fedotov <dmitry@uint32.ru>
2025-08-31 13:38:54 +03:00

29 lines
365 B
Go

package script
import (
"io"
)
type MemReader struct {
rows [][]string
curr int
}
func NewMemReader(records [][]string) *MemReader {
return &MemReader{
rows: records,
}
}
func (m *MemReader) Read() ([]string, error) {
if m.curr == len(m.rows) || len(m.rows) == 0 {
return nil, io.EOF
}
defer func() {
m.curr++
}()
return m.rows[m.curr], nil
}