frag-review/src/core/configuration.go

33 lines
755 B
Go
Raw Normal View History

package core
import (
"os"
"gopkg.in/yaml.v2"
)
type Config struct {
Gitea struct {
InstanceURL string `yaml:"instance_url"`
Owner string `yaml:"owner"`
Repository string `yaml:"repository"`
Token string
} `yaml:"gitea"`
Language struct {
OnSeparateLine bool `yaml:"on_separate_line"`
Opening string `yaml:"opening"`
Continuation string `yaml:"continuation"`
Closing string `yaml:"closing"`
} `yaml:"language"`
}
func LoadConfig(config *Config, filename string) {
configFile, err := os.Open(filename)
ExitOnError("Couldn't open config file", err)
defer configFile.Close()
decoder := yaml.NewDecoder(configFile)
err = decoder.Decode(&config)
ExitOnError("Couldn't decode config file", err)
}