Matheus 6 years ago
parent
commit
529f900ac3
3 changed files with 14 additions and 6 deletions
  1. 9 1
      core/database/database.go
  2. 3 3
      src/config/config.go
  3. 2 2
      src/config/routes.go

+ 9 - 1
core/database/database.go

@@ -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)

+ 3 - 3
src/config/config.go

@@ -1,11 +1,11 @@
1 1
 package config
2 2
 
3
+/* SERVER CONFIGURATION */
3 4
 const SERVER_PORT = 8080
4 5
 
5
-const DATA_SOURCE = "hml:spr777hml@tcp(208.97.141.22:3306)/hml_mkt_sprinta?parseTime=true"
6
-
6
+/* DATABASE CONFIGURATION */
7 7
 const DATABASE_HOST = "208.97.141.22"
8 8
 const DATABASE_PORT = "3306"
9
-const DATABASE_SCHEMA = "hml_mkt_sprinta"
10 9
 const DATABASE_USER = "hml"
11 10
 const DATABASE_PASS = "spr777hml"
11
+const DATABASE_SCHEMA = "hml_mkt_sprinta"

+ 2 - 2
src/config/routes.go

@@ -8,7 +8,7 @@ import (
8 8
 //Routes rotas de acesso
9 9
 var Routes = router.Routes{
10 10
 	router.Route{
11
-		`\/(.*)`,
12
-		test.Inicial,
11
+		Pattern: `\/(.*)`,
12
+		Handler: test.Inicial,
13 13
 	},
14 14
 }