Line | |
---|
1 | package config
|
---|
2 |
|
---|
3 | import (
|
---|
4 | "gopkg.in/ini.v1"
|
---|
5 | )
|
---|
6 |
|
---|
7 | var Config struct {
|
---|
8 | Debug bool
|
---|
9 | ListenAddress string
|
---|
10 | Key string
|
---|
11 | IPV6 bool
|
---|
12 | RequestTimeout uint
|
---|
13 | FollowRedirect bool
|
---|
14 | MaxConnsPerHost uint
|
---|
15 | UrlParameter string
|
---|
16 | HashParameter string
|
---|
17 | ProxyEnv bool
|
---|
18 | }
|
---|
19 |
|
---|
20 | func ReadConfig(file string) error {
|
---|
21 | cfg, err := ini.Load(file)
|
---|
22 | if err != nil {
|
---|
23 | return err
|
---|
24 | }
|
---|
25 | Config.Debug, _ = cfg.Section("yukari").Key("debug").Bool()
|
---|
26 | Config.ListenAddress = cfg.Section("yukari").Key("listen").String()
|
---|
27 | Config.Key = cfg.Section("yukari").Key("key").String()
|
---|
28 | Config.IPV6, _ = cfg.Section("yukari").Key("ipv6").Bool()
|
---|
29 | Config.RequestTimeout, _ = cfg.Section("yukari").Key("timeout").Uint()
|
---|
30 | Config.FollowRedirect, _ = cfg.Section("yukari").Key("followredirect").Bool()
|
---|
31 | Config.MaxConnsPerHost, _ = cfg.Section("yukari").Key("max_conns_per_host").Uint()
|
---|
32 | Config.UrlParameter = cfg.Section("yukari").Key("urlparam").String()
|
---|
33 | Config.HashParameter = cfg.Section("yukari").Key("hashparam").String()
|
---|
34 | Config.ProxyEnv, _ = cfg.Section("yukari").Key("proxyenv").Bool()
|
---|
35 | return nil
|
---|
36 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.