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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package conf
import "git.168cad.top/zhengqiuyun/rym-util/util"
type Config struct {
ServerName string
Env string
HttpPort int
LogLevel string
LogColorful bool
LogResponseLength int
LogShowSql bool
Redis RedisConf
Elasticsearch EsConf
Mysql MysqlConf
}
func BaseConfig(conf Config) {
if util.IsEmpty(&conf.ServerName) {
panic("ServerName error")
} else {
ServerName = conf.ServerName
}
if util.IsEmpty(&conf.Env) {
panic("Env error")
} else {
Env = conf.Env
}
if conf.HttpPort < 1024 {
panic("HttpPort error")
} else {
HttpPort = conf.HttpPort
}
if util.IsEmpty(&conf.LogLevel) {
LogLevel = "DEBUG"
} else {
LogLevel = conf.LogLevel
}
LogColorful = conf.LogColorful
LogResponseLength = conf.LogResponseLength
LogShowSql = conf.LogShowSql
Es = conf.Elasticsearch
Redis = conf.Redis
MySql = conf.Mysql
}
//Base conf
var ServerName string
var Env string
var HttpPort int
//log conf
var LogLevel = "DEBUG"
var LogColorful = true
var LogResponseLength int
var LogShowSql = true
//Redis conf
type RedisConf struct {
RedisHost string
RedisPort int
RedisPwd string
RedisDb int
}
var Redis = RedisConf{}
//ES conf
type EsConf struct {
ServerHost string
ServerPort int
}
var Es = EsConf{}
//Mysql conf
type MysqlConf struct {
Host string
Port int
User string
Password string
}
var MySql = MysqlConf{}