package main import ( // External "github.com/jmoiron/sqlx" _ "github.com/lib/pq" // Standard _ "database/sql" "fmt" "log" ) var ( dbConn string db *sqlx.DB ) func dbInit() { dbConn = fmt.Sprintf( "host=%s port=%d user=%s password=%s dbname=%s sslmode=disable", config.Database.Host, config.Database.Port, config.Database.Username, config.Database.Password, config.Database.Name, ) log.Printf( "\x1b[32mNotes\x1b[0m Connecting to database %s:%d\n", config.Database.Host, config.Database.Port, ) var err error db, err = sqlx.Connect("postgres", dbConn) if err != nil { panic(err) } } // vim: foldmethod=marker