Skip to content

Commit 6e1ebb6

Browse files
author
gbbr
committed
Added back defer
1 parent 511587e commit 6e1ebb6

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎chapter7/patterns/pool/main/main.go‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,11 @@ func performQueries(query int, p pool.Interface) {
8282
return
8383
}
8484

85+
// Release the connection back to the pool.
86+
defer p.Release(conn)
87+
8588
// Wait to simulate a query response.
8689
time.Sleep(time.Duration(rand.Intn(1000)) * time.Millisecond)
8790
fmt.Printf("Query: QID[%d] CID[%d]\n", query, conn.(*dbConnection).ID)
8891

89-
// Release the connection back to the pool.
90-
p.Release(conn)
9192
}

0 commit comments

Comments
 (0)