-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain.go
37 lines (32 loc) · 785 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
package main
import (
"errors"
"fmt"
"os"
"rest-geoip/internal/config"
"rest-geoip/internal/errortypes"
"rest-geoip/internal/maxmind"
"rest-geoip/internal/router"
"rest-geoip/internal/signals"
)
func main() {
config.Init()
signals.Trap()
err := maxmind.GetInstance().Open()
if err != nil {
var ErrDatabaseNotFound *errortypes.ErrorDatabaseNotFound
if errors.As(errors.Unwrap(err), &ErrDatabaseNotFound) {
fmt.Println(err)
fmt.Println("Attempting to fetch database")
fetchErr := maxmind.GetInstance().Update()
if fetchErr != nil {
fmt.Println(fetchErr)
os.Exit(1)
}
} else {
fmt.Println("Error: Maxmind database not opened during initialization. Please check that it exists and is readable.")
os.Exit(1)
}
}
router.InitRouter()
}