1
0
mirror of https://github.com/zhashkevych/go-sqlxmock.git synced 2025-11-29 21:57:41 +02:00

Create a single row from an interface list - #1

This commit is contained in:
Hebo
2014-02-12 17:02:35 -08:00
parent c33b881467
commit 936255418e

14
rows.go
View File

@@ -40,6 +40,20 @@ func (r *rows) Next(dest []driver.Value) error {
return nil
}
func RowFromInterface(columns []string, values ...interface{}) driver.Rows {
rs := &rows{}
rs.cols = columns
row := make([]driver.Value, len(columns))
for i, v := range values {
row[i] = v
}
rs.rows = append(rs.rows, row)
return rs
}
// RowsFromCSVString creates Rows from CSV string
// to be used for mocked queries. Returns sql driver Rows interface
func RowsFromCSVString(columns []string, s string) driver.Rows {