6481e90a0c
* Gofmt friendly Keeping Go source code in line with what they preconize * Golint Friendly Next So I have made some variables unexported Added comments in every function that I know what it does Removed some deprecated stuff that I was sure of Added a comment on possible deprecated methods "Is it deprecated?" Changed some variable/method name according to golint recommendations * Update filelist.go
32 lignes
650 o
Go
32 lignes
650 o
Go
package sqlite
|
|
|
|
import (
|
|
"database/sql"
|
|
|
|
_ "github.com/mattn/go-sqlite3" // Need for sqlite
|
|
)
|
|
|
|
// queryEvent is a queued event to be executed in a pipeline to ensure that sqlite access is done from 1 goroutine
|
|
type queryEvent struct {
|
|
query string
|
|
param []interface{}
|
|
handleResult func(*sql.Rows, error)
|
|
}
|
|
|
|
// New : Create a new database
|
|
func New(param string) (db *Database, err error) {
|
|
db = new(Database)
|
|
db.conn, err = sql.Open("sqlite3", param)
|
|
if err == nil {
|
|
db.query = make(chan *queryEvent, 128)
|
|
} else {
|
|
db = nil
|
|
}
|
|
return
|
|
}
|
|
|
|
// Database structure
|
|
type Database struct {
|
|
conn *sql.DB
|
|
query chan *queryEvent
|
|
}
|