-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
53 lines (42 loc) · 1.11 KB
/
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
// main.go
package main
import (
"log"
"os"
"strconv"
"github.com/joho/godotenv"
)
type config struct {
AppDbUsername string `env:"APP_DB_USERNAME,file"`
AppDbPassword string `env:"APP_DB_PASSWORD,file"`
AppDbName string `env:"APP_DB_NAME,file"`
}
func main() {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
a := App{}
wantsToDropDatabase := os.Getenv("WANTS_TO_DROP_DATABASE")
wantsToWriteData := os.Getenv("WANTS_TO_WRITE_DATA")
wantsToMakeMigrations := os.Getenv("WANTS_TO_MAKE_MIGRATIONS")
wantsToDropDatabaseBool, err := strconv.ParseBool(wantsToDropDatabase)
if err != nil {
log.Fatal(err)
}
wantsToWriteDataBool, err := strconv.ParseBool(wantsToWriteData)
if err != nil {
log.Fatal(err)
}
wantsToMakeMigrationsBool, err := strconv.ParseBool(wantsToMakeMigrations)
if err != nil {
log.Fatal(err)
}
a.wantsToDropDatabase = wantsToDropDatabaseBool
a.Initialize(
os.Getenv("APP_DB_USERNAME"),
os.Getenv("APP_DB_PASSWORD"),
os.Getenv("APP_DB_NAME"),
os.Getenv("SECRET_KEY"))
a.Run(":8010", wantsToWriteDataBool, wantsToMakeMigrationsBool)
}