You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
349 B
Go
20 lines
349 B
Go
package db
|
|
|
|
import (
|
|
"database/sql"
|
|
"fmt"
|
|
)
|
|
|
|
var handle *sql.DB
|
|
|
|
func Init(username, password, protocol, address, database string) error {
|
|
db, err := sql.Open("mysql", username+":"+password+"@"+protocol+"("+address+")/"+database)
|
|
if err != nil {
|
|
return fmt.Errorf("failed to open database connection: %s", err)
|
|
}
|
|
|
|
handle = db
|
|
|
|
return nil
|
|
}
|