-
Notifications
You must be signed in to change notification settings - Fork 0
/
read_config.go
79 lines (78 loc) · 1.35 KB
/
read_config.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
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
package utils
// import (
// "encoding/json"
// "io/ioutil"
// "os"
// )
//
// type ServerCfg struct {
// Name string
// ServerPort int
// }
//
// type MysqlCfg struct {
// Host string
// Port int
// User string
// Password string
// DataBase string
// }
//
// type RedisCfg struct {
// Host string
// Port int
// Password string
// }
//
// type Config struct {
// // server
// Server ServerCfg
// // mysql
// Mysql MysqlCfg
// // redis
// Redis RedisCfg
// // config
// ConfigPath string
// }
//
// func (g *Config) LoadConfig() error {
// if isExists, err := IsFileExist(g.ConfigPath); !isExists || err != nil {
// return err
// }
//
// data, err := ioutil.ReadFile(g.ConfigPath)
// if err != nil {
// return err
// }
//
// err = json.Unmarshal(data, g)
// if err != nil {
// return err
// }
// return nil
// }
//
// var GConfig *Config
//
// func init() {
// pwd, err := os.Getwd()
// if err != nil {
// pwd = "."
// }
// GConfig = &Config{
// Server: ServerCfg{Name: "localhost"},
// Mysql: MysqlCfg{
// Host: "localhost",
// Port: 3306,
// User: "root",
// Password: "123456",
// DataBase: "mysql",
// },
// Redis: RedisCfg{
// Host: "localhost",
// Port: 6379,
// Password: "123456",
// },
// ConfigPath: pwd + "/src/utils/server.json",
// }
// }