package main import "fmt" import "github.com/sirupsen/logrus" import "github.com/sneak/sircd/sircd" import "github.com/spf13/viper" var Version string var Buildtime string func main() { // set up logging log := logrus.New() log.SetLevel(logrus.DebugLevel) log.SetReportCaller(true) log.Println("sircd starting up") c := viper.New() // default config variables c.SetDefault("myhostname", "irc.example.com") c.SetDefault("network", "ExampleNet") c.SetDefault("admin", "webmaster@example.com") c.SetDefault("version", Version) c.SetDefault("buildtime", Buildtime) // read config file c.SetConfigName("sircd") // name of config file (without extension) c.AddConfigPath("/etc/sircd/") // path to look for the config file in c.AddConfigPath("$HOME/.config/sircd") // call multiple times to add many search paths c.AddConfigPath(".") // optionally look for config in the working directory err := c.ReadInConfig() // Find and read the config file if err != nil { // Handle errors reading the config file panic(fmt.Errorf("Fatal error config file: %s \n", err)) } // instantiate server s := sircd.New(c) // give it our logger s.SetLogger(log) // run it s.Start() }