func TestLoadConfig(t *testing.T) { withTempConfigFile(t, func(filename string) { actual, err := config.LoadConfig(filename) if err != nil { t.Error(err.Error()) return } inputs := []string{"file:///var/log/nginx/access.log", "file:///var/log/nginx/error.log"} expected := &config.Config{Inputs: inputs} if !reflect.DeepEqual(expected, actual) { t.Errorf("got %v\nwant %v", expected, actual) return } }) }
func main() { conf, err := config.LoadConfig("config.json") if err != nil { panic("load config error:" + err.Error()) } readCh := make(chan []byte, 200) prepareReader(conf, readCh) broadcaster = prepareWriter(readCh) setupWebsocketUrl("/log/", broadcaster) setupIndexPage() err = http.ListenAndServe(":8080", nil) if err != nil { panic("ListenAndServe: " + err.Error()) } }