赛思维服务调研
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
851 B

package conf
import (
"gopkg.in/yaml.v2"
"os"
)
type EnvConfig struct {
DbType string `yaml:"dbtype"`
Server string `yaml:"server"`
Ip string `yaml:"ip"`
User string `yaml:"user"`
Password string `yaml:"password"`
DbName string `yaml:"dbname"`
Port int `yaml:"port"`
TemplatePath string `yaml:"templatepath"`
ReadTaskInterval int `yaml:"readtaskinterval"`
PrinterType string `yaml:"printertype"`
Finr int `yaml:"finr"`
Inbox string `yaml:"inbox"`
Outbox string `yaml:"outbox"`
Log string `yaml:"log"`
}
//read yaml config
//注:path为yaml或yml文件的路径
func ReadYamlConfig(path string) (*EnvConfig,error){
conf := &EnvConfig{}
f, err := os.Open(path)
if err != nil {
return nil,err
} else {
yaml.NewDecoder(f).Decode(conf)
}
defer f.Close()
return conf,nil
}