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
 	"database/sql"
4
 	"database/sql"
5
 	"log"
5
 	"log"
6
 
6
 
7
+	"../../src/config"
7
 	_ "github.com/go-sql-driver/mysql"
8
 	_ "github.com/go-sql-driver/mysql"
8
 )
9
 )
9
 
10
 
11
 
12
 
12
 func Init() error {
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
 	var err error
22
 	var err error
15
 
23
 
16
-	DB, err = sql.Open("mysql", dataSourceName)
24
+	DB, err = sql.Open("mysql", dataSource)
17
 
25
 
18
 	if err != nil {
26
 	if err != nil {
19
 		log.Panic(err)
27
 		log.Panic(err)

+ 3 - 3
src/config/config.go

1
 package config
1
 package config
2
 
2
 
3
+/* SERVER CONFIGURATION */
3
 const SERVER_PORT = 8080
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
 const DATABASE_HOST = "208.97.141.22"
7
 const DATABASE_HOST = "208.97.141.22"
8
 const DATABASE_PORT = "3306"
8
 const DATABASE_PORT = "3306"
9
-const DATABASE_SCHEMA = "hml_mkt_sprinta"
10
 const DATABASE_USER = "hml"
9
 const DATABASE_USER = "hml"
11
 const DATABASE_PASS = "spr777hml"
10
 const DATABASE_PASS = "spr777hml"
11
+const DATABASE_SCHEMA = "hml_mkt_sprinta"

+ 2 - 2
src/config/routes.go

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