32 lines
650 B
Go
32 lines
650 B
Go
package main
|
|
|
|
import (
|
|
"io/ioutil"
|
|
|
|
"gopkg.in/yaml.v2"
|
|
)
|
|
|
|
// Config of warehost webserver
|
|
type Config struct {
|
|
Database string `yaml:"database"`
|
|
Log struct {
|
|
Path string `yaml:"path"`
|
|
} `yaml:"log"`
|
|
DatabaseDebug bool `yaml:"databasedebug"`
|
|
FTPPath string `yaml:"data"`
|
|
Host string `yaml:"host"`
|
|
Web string `yaml:"web"`
|
|
Port int `yaml:"port"`
|
|
}
|
|
|
|
// ReadConfigFile reads a config models by path to a yml file
|
|
func ReadConfigFile(path string) *Config {
|
|
config := &Config{}
|
|
file, _ := ioutil.ReadFile(path)
|
|
err := yaml.Unmarshal(file, &config)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return config
|
|
}
|