goufy/pkg/config/config.go

28 lines
411 B
Go
Raw Normal View History

2021-04-02 18:53:25 +02:00
package config
import (
"io/ioutil"
yaml "gopkg.in/yaml.v3"
)
const CONFIGFILE = "config.yaml"
type Config struct {
host string `yaml:"host"`
port int `yaml:"port"`
}
func (c *Config) readConfig() (*Config, error) {
yamlFile, err := ioutil.ReadFile(CONFIGFILE)
if err != nil {
return nil, err
}
err = yaml.Unmarshal([]byte(yamlFile), c)
if err != nil {
return nil, err
}
return c, nil
}