Эх сурвалжийг харах

[go/gin] Ensure rows are closed

kisesy 6 сар өмнө
parent
commit
abdb3336e9

+ 1 - 0
frameworks/Go/gin/gin-src/hello.go

@@ -99,6 +99,7 @@ func fortunes(c *gin.Context) {
 		c.AbortWithError(500, err)
 		c.AbortWithError(500, err)
 		return
 		return
 	}
 	}
+	defer rows.Close() // Ensure rows are closed
 
 
 	fortunes := make(Fortunes, 0)
 	fortunes := make(Fortunes, 0)
 	for rows.Next() { //Fetch rows
 	for rows.Next() { //Fetch rows

+ 1 - 0
frameworks/Go/gin/gin-std/main.go

@@ -99,6 +99,7 @@ func fortunes(c *gin.Context) {
 		c.AbortWithError(500, err)
 		c.AbortWithError(500, err)
 		return
 		return
 	}
 	}
+	defer rows.Close() // Ensure rows are closed
 
 
 	fortunes := make(Fortunes, 0)
 	fortunes := make(Fortunes, 0)
 	for rows.Next() { //Fetch rows
 	for rows.Next() { //Fetch rows