-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinitConf.go
More file actions
47 lines (39 loc) · 880 Bytes
/
initConf.go
File metadata and controls
47 lines (39 loc) · 880 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 parseconf
var Cfg *Config
type Global struct {
Host string `conf:"host"`
Port int64 `conf:"port"`
}
type LimitConfig struct {
Count int `conf:"count"`
Second int `conf:"second"`
}
type RedisConfig struct {
Addr string `conf:"addr"`
RPort int64 `conf:"port"`
Password string `conf:"password"`
DB int `conf:"db"`
}
type MysqlConfig struct {
MHost string `conf:"host"`
MPort int64 `conf:"port"`
UserName string `conf:"username"`
PassWord string `conf:"password"`
DBName string `conf:"dbname"`
}
// Config 配置文件结构体
type Config struct {
Global `conf:"global"`
LimitConfig `conf:"limit"`
RedisConfig `conf:"redis"`
MysqlConfig `conf:"mysql"`
}
func checkConf() {
//这里做一些判断
}
func InitConf(confName string) (err error) {
Cfg = &Config{}
err = parseConf(confName, Cfg)
checkConf()
return
}