|
@@ -4,6 +4,7 @@ import (
|
4
|
4
|
"database/sql"
|
5
|
5
|
"log"
|
6
|
6
|
|
|
7
|
+ "../../src/config"
|
7
|
8
|
_ "github.com/go-sql-driver/mysql"
|
8
|
9
|
)
|
9
|
10
|
|
|
@@ -11,9 +12,16 @@ var DB *sql.DB
|
11
|
12
|
|
12
|
13
|
func Init() error {
|
13
|
14
|
|
|
15
|
+ //user:pass@tcp(host:port)/schema?parseTime=true
|
|
16
|
+ var dataSource = config.DATABASE_USER + ":" +
|
|
17
|
+ config.DATABASE_PASS + "@tcp(" +
|
|
18
|
+ config.DATABASE_HOST + ":" +
|
|
19
|
+ config.DATABASE_PORT + ")/" +
|
|
20
|
+ config.DATABASE_SCHEMA + "?parseTime=true"
|
|
21
|
+
|
14
|
22
|
var err error
|
15
|
23
|
|
16
|
|
- DB, err = sql.Open("mysql", dataSourceName)
|
|
24
|
+ DB, err = sql.Open("mysql", dataSource)
|
17
|
25
|
|
18
|
26
|
if err != nil {
|
19
|
27
|
log.Panic(err)
|