-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.go
More file actions
47 lines (38 loc) · 921 Bytes
/
main.go
File metadata and controls
47 lines (38 loc) · 921 Bytes
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
package main
import (
"github.com/brasilcep/api/api"
"github.com/brasilcep/api/config"
"github.com/brasilcep/api/database"
"github.com/brasilcep/api/logger"
"github.com/brasilcep/api/zipcodes"
)
var (
Version = "dev"
Commit = "none"
Repo = "unknown"
Compiler = "unknown"
)
func main() {
config := config.NewConfig()
buildInfo := api.BuildInfo{
Version: Version,
Commit: Commit,
Repo: Repo,
Compiler: Compiler,
}
log_level := config.GetString("log.level")
logger := logger.NewLogger(log_level)
database.NewDatabase(config, logger)
mode := config.GetString("mode")
switch mode {
case "listen":
api := api.NewAPI(config, logger, buildInfo)
api.Listen()
case "seed":
dnePath := config.GetString("db.raw.path")
zipcodesImporter := zipcodes.NewZipCodeImporter(logger)
zipcodesImporter.PopulateZipcodes(dnePath)
default:
logger.Fatal("Invalid mode specified")
}
}