fix: potential context leak
This commit is contained in:
		@ -19,7 +19,8 @@ func OpenDB(dsn string) (*sql.DB, error) {
 | 
				
			|||||||
	db.SetMaxOpenConns(10)
 | 
						db.SetMaxOpenConns(10)
 | 
				
			||||||
	db.SetMaxIdleConns(10)
 | 
						db.SetMaxIdleConns(10)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctx, _ := context.WithTimeout(context.Background(), 3*time.Second)
 | 
						ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
 | 
				
			||||||
 | 
						defer cancel()
 | 
				
			||||||
	err = db.PingContext(ctx)
 | 
						err = db.PingContext(ctx)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		fmt.Println(err)
 | 
							fmt.Println(err)
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user