18 lines
		
	
	
		
			263 B
		
	
	
	
		
			Go
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			18 lines
		
	
	
		
			263 B
		
	
	
	
		
			Go
		
	
	
		
			Executable File
		
	
	
	
	
package db
 | 
						|
 | 
						|
import (
 | 
						|
	"database/sql"
 | 
						|
	_ "github.com/lib/pq"
 | 
						|
)
 | 
						|
 | 
						|
func NewConnection(dsn string) (*sql.DB, error) {
 | 
						|
	db, err := sql.Open("postgres", dsn)
 | 
						|
	if err != nil {
 | 
						|
		return nil, err
 | 
						|
	}
 | 
						|
	if err := db.Ping(); err != nil {
 | 
						|
		return nil, err
 | 
						|
	}
 | 
						|
	return db, nil
 | 
						|
}
 |