|
|
@ -25,14 +25,12 @@ import (
|
|
|
|
_ "github.com/go-sql-driver/mysql"
|
|
|
|
_ "github.com/go-sql-driver/mysql"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
var handle *sql.DB
|
|
|
|
handle *sql.DB
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func Init(username, password, protocol, address, database string) error {
|
|
|
|
func Init(username, password, protocol, address, database string) error {
|
|
|
|
var err error
|
|
|
|
var err error
|
|
|
|
|
|
|
|
|
|
|
|
handle, err = sql.Open("mysql", username+":"+password+"@"+protocol+"("+address+":13306)/"+database)
|
|
|
|
handle, err = sql.Open("mysql", username+":"+password+"@"+protocol+"("+address+":3306)/"+database)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("failed to open database connection: %s", err)
|
|
|
|
return fmt.Errorf("failed to open database connection: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|