-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (37 loc) · 952 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
package main
import (
"database/sql"
"log"
"github.com/dhiyaaulauliyaa/learn-go/api"
"github.com/dhiyaaulauliyaa/learn-go/config"
db "github.com/dhiyaaulauliyaa/learn-go/db/sqlc"
"github.com/dhiyaaulauliyaa/learn-go/util"
_ "github.com/lib/pq"
)
func main() {
/* Load Config File */
appConfig, err := util.LoadConfig(".")
if err != nil {
log.Fatal("Error when loading config: ", err)
}
/* Connect Database */
conn, err := sql.Open(appConfig.DBDriver, appConfig.DBSource)
if err != nil {
log.Fatal("Error when connecting to databse: ", err)
}
/* Init Firebase */
firebaseApp := config.SetupFirebase()
/* Create Server */
server, err := api.NewServer(
db.NewStore(conn),
*config.SetupFirebaseAuth(firebaseApp),
)
if err != nil {
log.Fatal("Error when creating server: ", err)
}
/* Start Server */
err = server.Start(appConfig.ServerAddress)
if err != nil {
log.Fatal("Error when starting server: ", err)
}
}