|
@@ -1,4 +1,4 @@
|
1
|
|
-package models
|
|
1
|
+package database
|
2
|
2
|
|
3
|
3
|
import (
|
4
|
4
|
"database/sql"
|
|
@@ -7,19 +7,19 @@ import (
|
7
|
7
|
_ "github.com/go-sql-driver/mysql"
|
8
|
8
|
)
|
9
|
9
|
|
10
|
|
-var db *sql.DB
|
|
10
|
+var DB *sql.DB
|
11
|
11
|
|
12
|
12
|
func Init(dataSourceName string) error {
|
13
|
13
|
|
14
|
14
|
var err error
|
15
|
15
|
|
16
|
|
- db, err = sql.Open("mysql", dataSourceName)
|
|
16
|
+ DB, err = sql.Open("mysql", dataSourceName)
|
17
|
17
|
|
18
|
18
|
if err != nil {
|
19
|
19
|
log.Panic(err)
|
20
|
20
|
}
|
21
|
21
|
|
22
|
|
- if err = db.Ping(); err != nil {
|
|
22
|
+ if err = DB.Ping(); err != nil {
|
23
|
23
|
log.Panic(err)
|
24
|
24
|
}
|
25
|
25
|
|