<commit_before>package main

import (
	"database/sql"
	"net/http"
	"runtime"

	"bitbucket.org/carbocation/nrsc"
	"github.com/carbocation/forum.git/forum"
	"github.com/gorilla/mux"
	"github.com/gorilla/sessions"
	_ "github.com/lib/pq"
)

var (
	db        *sql.DB     = initdb()                                                                                   //db maintains a pool of connections to our database of choice 
	appsecret             = `<KEY>` //64 bit random string generated with `openssl rand -base64 64`
	store                 = sessions.NewFilesystemStore("", []byte(appsecret))                                         //With an empty first argument, this will put session files in os.TempDir() (/tmp)
	router    *mux.Router = mux.NewRouter()                                                                            //Dynamic content is managed by handlers pointed at by the router 
)

func init() {
	runtime.GOMAXPROCS(runtime.NumCPU())
}

func main() {
	// Defer the close of the DB in the main function so we'll have a pool of connections maintained until the program exits
	defer db.Close()

	//Initialize the forum package
	forum.Initialize(db)

	//Bundled static assets are handled by nrsc
	nrsc.Handle("/static/")

	//Create a subrouter for GET requests
	g := router.Methods("GET").Subrouter()
	g.Handle("/", handler(indexHandler)).Name("index")
	g.Handle("/thread/{id:[0-9]+}", handler(threadHandler)).Name("thread")
	g.Handle("/login", handler(loginHandler)).Name("login")
	g.Handle("/logout", handler(logoutHandler)).Name("logout")

	//Create a subrouter for POST requests
	p := router.Methods("POST").Subrouter()
	p.Handle("/thread", handler(postThreadHandler)).Name("postThread")
	p.Handle("/login", handler(postLoginHandler)).Name("postLogin")

	//Notify the http package about our router
	http.Handle("/", router)

	//Launch the server
	if err := http.ListenAndServe("localhost:9999", nil); err != nil {
		panic(err)
	}
}

func initdb() *sql.DB {
	db, err := sql.Open("postgres", "dbname=forumtest sslmode=disable")
	if err != nil {
		panic(err)
	}
<commit_msg>Adding a panic if the connection fails.<commit_after>package main

import (
	"database/sql"
	"fmt"
	"net/http"
	"runtime"

	"bitbucket.org/carbocation/nrsc"
	"github.com/carbocation/forum.git/forum"
	"github.com/gorilla/mux"
	"github.com/gorilla/sessions"
	_ "github.com/lib/pq"
)

var (
	db        *sql.DB     = initdb()                                                                                   //db maintains a pool of connections to our database of choice 
	appsecret             = `<KEY>` //64 bit random string generated with `openssl rand -base64 64`
	store                 = sessions.NewFilesystemStore("", []byte(appsecret))                                         //With an empty first argument, this will put session files in os.TempDir() (/tmp)
	router    *mux.Router = mux.NewRouter()                                                                            //Dynamic content is managed by handlers pointed at by the router 
)

func init() {
	runtime.GOMAXPROCS(runtime.NumCPU())
}

func main() {
	// Defer the close of the DB in the main function so we'll have a pool of connections maintained until the program exits
	defer db.Close()

	//Initialize the forum package
	forum.Initialize(db)

	//Bundled static assets are handled by nrsc
	nrsc.Handle("/static/")

	//Create a subrouter for GET requests
	g := router.Methods("GET").Subrouter()
	g.Handle("/", handler(indexHandler)).Name("index")
	g.Handle("/thread/{id:[0-9]+}", handler(threadHandler)).Name("thread")
	g.Handle("/login", handler(loginHandler)).Name("login")
	g.Handle("/logout", handler(logoutHandler)).Name("logout")

	//Create a subrouter for POST requests
	p := router.Methods("POST").Subrouter()
	p.Handle("/thread", handler(postThreadHandler)).Name("postThread")
	p.Handle("/login", handler(postLoginHandler)).Name("postLogin")

	//Notify the http package about our router
	http.Handle("/", router)

	//Launch the server
	if err := http.ListenAndServe("localhost:9999", nil); err != nil {
		panic(err)
	}
}

func initdb() *sql.DB {
	db, err := sql.Open("postgres", "dbname=projects user=askbitcoin password=<PASSWORD> sslmode=disable")
	if err != nil {
		fmt.Println("Panic: "+err.Error())
		panic(err)
	}

{'fraction_non_alphanumeric': 0.13813184253435826, 'fraction_numerical': 0.005590496156533892, 'mean_word_length': 2.6953528399311533, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '541633', 'n_tokens_mistral': 1300, 'n_tokens_neox': 1238, 'n_words': 349}