move db init/open functions into a single file

This commit is contained in:
Jeremy Latt 2014-03-01 15:02:24 -08:00
parent 542744d52a
commit b421971b61
3 changed files with 34 additions and 31 deletions

View file

@ -7,7 +7,6 @@ import (
"database/sql"
"encoding/binary"
"fmt"
_ "github.com/mattn/go-sqlite3"
"log"
"net"
"os"
@ -36,17 +35,12 @@ type Server struct {
}
func NewServer(config *Config) *Server {
db, err := sql.Open("sqlite3", config.Database())
if err != nil {
log.Fatal(err)
}
server := &Server{
channels: make(ChannelNameMap),
clients: make(ClientNameMap),
commands: make(chan Command, 16),
ctime: time.Now(),
db: db,
db: OpenDB(config.Database()),
idle: make(chan *Client, 16),
motdFile: config.MOTD,
name: config.Name,