32 lines
599 B
Go
32 lines
599 B
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/Unknwon/goconfig"
|
|
"log"
|
|
"os"
|
|
)
|
|
|
|
type ClientCfg struct {
|
|
Area string
|
|
GetListUrl string
|
|
PostStatusUrl string
|
|
}
|
|
|
|
func (c *ClientCfg) GetCfg() {
|
|
var cfg *goconfig.ConfigFile
|
|
cpath, _ := os.Getwd()
|
|
config, err := goconfig.LoadConfigFile(cpath + "/config/client.ini") //加载配置文件
|
|
if err != nil {
|
|
log.Println("get config file error")
|
|
os.Exit(-1)
|
|
}
|
|
cfg = config
|
|
|
|
client, _ := cfg.GetSection("client")
|
|
cc, _ := client["get_list_url"]
|
|
fmt.Print(cc)
|
|
c.PostStatusUrl, _ = client["post_list_url"]
|
|
c.Area, _ = client["area"]
|
|
}
|