-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
38 lines (30 loc) · 912 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
package main
import (
"github.com/aurelius15/go-skeleton/cmd"
"github.com/aurelius15/go-skeleton/internal/config"
"github.com/aurelius15/go-skeleton/internal/log"
"github.com/aurelius15/go-skeleton/internal/reflection"
"github.com/aurelius15/go-skeleton/internal/storage"
"github.com/go-redis/redis/v8"
)
func main() {
configs := config.ParseConfig()
logger := log.NewLogger(configs.AppMode == config.ProdMode)
log.SetDefault(logger)
defer log.GracefulSync(logger)
storage.SetInstance(redis.NewClient(&redis.Options{
Addr: configs.RedisPort,
}))
inter, err := reflection.FirstNotNilInterface(*configs)
if err != nil {
log.Default().Panic(err.Error())
}
cmdConfig, ok := inter.(config.Configure)
if !ok {
log.Default().Panic("wrong command's interface")
}
if command, ok := cmd.CommandCollection[cmdConfig.Command()]; ok {
command.BindConfig(cmdConfig)
command.Execute()
}
}