29 lines
365 B
Go
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
|
|
}
|