You've already forked go-sqlxmock
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:
14
rows.go
14
rows.go
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user