-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
56 lines (44 loc) · 879 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
import (
"database/sql"
"fmt"
"resto/handler"
"resto/repository"
"resto/server"
"resto/service"
"github.com/gin-gonic/gin"
_ "github.com/lib/pq"
)
const (
user = "postgres"
password = "handoko"
dbname = "resto"
port = 5432
ssl = "disable"
time = "Asia/Jakarta"
localhost = "localhost:5000"
)
func main() {
psqlInfo := fmt.Sprintf("user=%s password=%s dbname=%s port=%d sslmode=%s TimeZone=%s",
user, password, dbname, port, ssl, time)
db, err := sql.Open("postgres", psqlInfo)
if err != nil {
panic(err)
}
repository := repository.Repository{
DB: db,
}
service := service.Service{
Repository: repository,
}
handler := handler.Handler{
Service: service,
}
router := gin.Default()
start := server.Server{
Router: router,
Handler: &handler,
}
start.StartServer()
router.Run(localhost)
}