update config
This commit is contained in:
parent
184e663f98
commit
d55782213c
|
@ -1,36 +0,0 @@
|
|||
package utils
|
||||
|
||||
import (
|
||||
"gopkg.in/yaml.v2"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Server struct {
|
||||
Host string `yaml:"host"`
|
||||
Port int16 `yaml:"port"`
|
||||
MaxConns int `yaml:"maxconns"`
|
||||
}
|
||||
Log struct {
|
||||
Outgoing bool `yaml:"outgoing"`
|
||||
Incoming bool `yaml:"incoming"`
|
||||
}
|
||||
}
|
||||
|
||||
func LoadConfig() Config {
|
||||
data, err := ioutil.ReadFile("./config.yml")
|
||||
if err != nil {
|
||||
log.Fatal("Failed to read config file 'config.yml', check that it exists & try again.", err)
|
||||
}
|
||||
|
||||
config := Config{}
|
||||
|
||||
err = yaml.Unmarshal(data, &config)
|
||||
if err != nil {
|
||||
log.Fatal("Failed to unmarshal config file 'config.yml', check that its format is correct & try again.", err)
|
||||
}
|
||||
|
||||
log.Println("The file 'config.yml' has been successfully loaded.")
|
||||
return config
|
||||
}
|
Loading…
Reference in New Issue