func main() { // setOptions() http.HandleFunc("/", homeHandler) http.HandleFunc("/docs", docHandler) http.HandleFunc("/api/", apiHandler) http.ListenAndServe(fmt.Sprintf(":%d", config.Port()), nil) }
func init() { var port int64 flag.BoolVar(&Debug, "debug", false, "Activate debug prints to the console. Active if either this or the value in 'config.json' are set.") flag.Int64Var(&port, "port", 0, "Port. If set, this flag will override the value in 'config.json'.") flag.Parse() logs.Init(Debug) if err := config.Init("config.json", port); err != nil { log.Error("Error loading config file: %s\n", err) } if err := data.Init("data.json"); err != nil { log.Error("Error loading config file: %s\n", err) } log.Info("Running on port: %d", config.Port()) go SignalHandler(make(chan os.Signal, 1)) fmt.Println("Press Ctrl-C to shutdown...") }