func main() { var configFile string var showHelp bool fs := flag.NewFlagSet("hteed", flag.ContinueOnError) fs.SetOutput(ioutil.Discard) fs.StringVar(&configFile, "c", "", "") fs.StringVar(&configFile, "config", "/etc/hteed/hteed.conf", "") fs.BoolVar(&showHelp, "h", false, "") fs.BoolVar(&showHelp, "help", false, "") fs.Parse(os.Args[1:]) if showHelp { fmt.Printf("%s\n", usage) os.Exit(0) } c := loadConfig(configFile) if err := config.Configure(c); err != nil { fmt.Fprintf(os.Stderr, "%s\n", err.Error()) os.Exit(1) } http.ListenAndServe(c.Addr(), server.ServerHandler()) }
func init() { us := httptest.NewServer(http.HandlerFunc(fakeWebHandler)) cnf := &config.Config{ Address: "127.0.0.1", Port: 4000, RedisURL: ":6379", WebURL: us.URL, KeyPrefix: keyPrefix, Testing: true, } if err := config.Configure(cnf); err != nil { panic(err.Error()) } }