You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
596 B
Go
32 lines
596 B
Go
package core
|
|
|
|
import (
|
|
"io/ioutil"
|
|
|
|
"gopkg.in/yaml.v2"
|
|
)
|
|
|
|
type AppConfig struct {
|
|
DataFolder string `yaml:"data_folder"`
|
|
UserAddress string `yaml:"user"`
|
|
ShowFromMe bool `yaml:"show_from_me"`
|
|
VerifiedGroups bool `yaml:"verified_groups"`
|
|
}
|
|
|
|
type Config struct {
|
|
Deltachat map[string]string `yaml:"deltachat"`
|
|
App AppConfig `yaml:"app"`
|
|
}
|
|
|
|
func ConfigFromFile(filePath string) (*Config, error) {
|
|
fileContents, err := ioutil.ReadFile(filePath)
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
config := &Config{}
|
|
|
|
return config, yaml.Unmarshal(fileContents, config)
|
|
}
|