mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-22 02:52:00 -08:00
move db init/open functions into a single file
This commit is contained in:
parent
542744d52a
commit
b421971b61
3 changed files with 34 additions and 31 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue