Skip to content

Commit

Permalink
Fix example in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
olbrichattila committed Jul 20, 2024
1 parent eabda4b commit d82aa74
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ func initFunc(params ...interface{}) ([]interface{}, error) {
return nil, err
}
return []interface{}{db, rows}, nil
return []interface{}{db, stmt, rows}, nil
}
func deferFunc(params ...interface{}) error {
if len(params) != 2 {
if len(params) != 3 {
return fmt.Errorf("two parameter required in defer func")
}
Expand All @@ -233,13 +233,13 @@ func deferFunc(params ...interface{}) error {
}
func callback(i int, params ...interface{}) (interface{}, error) {
if len(params) != 2 {
if len(params) != 3 {
return nil, fmt.Errorf("two parameter required in callback")
}
rows, ok := params[1].(*sql.Rows)
rows, ok := params[2].(*sql.Rows)
if !ok {
return nil, fmt.Errorf("parameter 2 is not *sql.Stmt")
return nil, fmt.Errorf("parameter 2 is not *sql.Rows")
}
hasNextRow := rows.Next()
Expand All @@ -252,4 +252,5 @@ func callback(i int, params ...interface{}) (interface{}, error) {
return vehicle, nil
}
```

0 comments on commit d82aa74

Please sign in to comment.