Skip to content

Commit 65c4ffd

Browse files
authored
fix closure problem (#4)
closure problem cause stmt.queryrow con not reach i's value
1 parent cf15512 commit 65c4ffd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

benchmarks.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ func runPreparedQueryConcurrent(db *sql.DB, n int, co int) error {
287287
wg.Add(co)
288288

289289
for i := 0; i < co; i++ {
290-
go func() {
290+
go func(i int) {
291291
var id int
292292
var str string
293293
for {
@@ -302,7 +302,7 @@ func runPreparedQueryConcurrent(db *sql.DB, n int, co int) error {
302302
return
303303
}
304304
}
305-
}()
305+
}(i)
306306
}
307307
wg.Wait()
308308
stmt.Close()

0 commit comments

Comments
 (0)