1
0
Fork 0
mirror of https://github.com/alice-lg/birdwatcher.git synced 2025-03-09 00:00:05 +01:00

Don't shadow global conf in main

This commit is contained in:
Daniel Melani 2016-10-23 16:01:12 +02:00
parent b9ba065ba4
commit f3ca578629

View file

@ -16,7 +16,7 @@ import (
var debug int = 0
var slog *syslog.Writer // Our syslog connection
var conf Config
var conf *Config
type Match struct {
Expr string // The regular expression as a string.
@ -52,15 +52,14 @@ func parseconfig(filename string) (conf *Config, err error) {
return
}
fileconf := new(FileConfig)
if err = yaml.Unmarshal(contents, &fileconf); err != nil {
if err = yaml.Unmarshal(contents, &conf.Conf); err != nil {
return
}
conf.Res = make(map[string]RE)
// Build the regexps from the configuration.
for key, match := range fileconf.Matches {
for key, match := range conf.Conf.Matches {
var err error
var re RE
@ -102,11 +101,12 @@ func main() {
slog.Debug("birdwatcher starting")
conf, err := parseconfig(*configfile)
config, err := parseconfig(*configfile)
if err != nil {
slog.Err("Couldn't parse configuration file: " + err.Error())
os.Exit(-1)
}
conf = config
fmt.Printf("%v\n", conf)