Commit ebcb34c3 authored by gwenn's avatar gwenn

Golint

parent 3178e848
......@@ -24,6 +24,7 @@ import "unsafe"
// See ConfigThreadingMode
type ThreadingMode int32
// SQLite threading modes
const (
SingleThread ThreadingMode = C.SQLITE_CONFIG_SINGLETHREAD
MultiThread ThreadingMode = C.SQLITE_CONFIG_MULTITHREAD
......
......@@ -210,7 +210,7 @@ func (vc *csvTabCursor) Next() error {
}
return err
}
func (vc *csvTabCursor) Eof() bool {
func (vc *csvTabCursor) EOF() bool {
return vc.vTab.eof
}
func (vc *csvTabCursor) Column(c *Context, col int) error {
......@@ -254,7 +254,7 @@ func (db *Conn) ExportTableToCSV(dbName, table string, nullvalue string, headers
return s.ExportToCSV(nullvalue, headers, w)
}
// ExportTableToCSV export statement result to CSV.
// ExportToCSV export statement result to CSV.
// 'headers' flag turns output of headers on or off.
// NULL values are output as specified by 'nullvalue' parameter.
func (s *Stmt) ExportToCSV(nullvalue string, headers bool, w *yacr.Writer) error {
......@@ -283,6 +283,7 @@ func (s *Stmt) ExportToCSV(nullvalue string, headers bool, w *yacr.Writer) error
return w.Err()
}
// ImportConfig gathers import parameters.
type ImportConfig struct {
Name string // the name of the input; used only for error reports
Separator byte // CSV separator
......
......@@ -18,7 +18,7 @@ void* goSqlite3RollbackHook(sqlite3 *db, void *udp) {
return sqlite3_rollback_hook(db, goXRollbackHook, udp);
}
extern void goXUpdateHook(void *udp, int action, char const *dbName, char const *tableName, sqlite3_int64 rowId);
extern void goXUpdateHook(void *udp, int action, char const *dbName, char const *tableName, sqlite3_int64 rowID);
void* goSqlite3UpdateHook(sqlite3 *db, void *udp) {
return sqlite3_update_hook(db, goXUpdateHook, udp);
......
......@@ -74,7 +74,7 @@ func (c *Conn) RollbackHook(f RollbackHook, udp interface{}) {
}
// UpdateHook is the callback function signature.
type UpdateHook func(udp interface{}, a Action, dbName, tableName string, rowId int64)
type UpdateHook func(udp interface{}, a Action, dbName, tableName string, rowID int64)
type sqliteUpdateHook struct {
f UpdateHook
......@@ -82,9 +82,9 @@ type sqliteUpdateHook struct {
}
//export goXUpdateHook
func goXUpdateHook(udp unsafe.Pointer, action int, dbName, tableName *C.char, rowId C.sqlite3_int64) {
func goXUpdateHook(udp unsafe.Pointer, action int, dbName, tableName *C.char, rowID C.sqlite3_int64) {
arg := (*sqliteUpdateHook)(udp)
arg.f(arg.udp, Action(action), C.GoString(dbName), C.GoString(tableName), int64(rowId))
arg.f(arg.udp, Action(action), C.GoString(dbName), C.GoString(tableName), int64(rowID))
}
// UpdateHook registers a callback to be invoked each time a row is updated,
......
......@@ -27,11 +27,11 @@ func rollbackHook(d interface{}) {
}
}
func updateHook(d interface{}, a Action, dbName, tableName string, rowId int64) {
func updateHook(d interface{}, a Action, dbName, tableName string, rowID int64) {
if t, ok := d.(*testing.T); ok {
t.Logf("UPD: %d, %s.%s.%d\n", a, dbName, tableName, rowId)
t.Logf("UPD: %d, %s.%s.%d\n", a, dbName, tableName, rowID)
} else {
fmt.Printf("%s: %d, %s.%s.%d\n", d, a, dbName, tableName, rowId)
fmt.Printf("%s: %d, %s.%s.%d\n", d, a, dbName, tableName, rowID)
}
}
......
......@@ -8,7 +8,7 @@ package sqlite
import "fmt"
// This is the Go-language interface definition for the "intarray" or
// IntArray is the Go-language interface definition for the "intarray" or
// integer array virtual table for SQLite.
//
// The intarray virtual table is designed to facilitate using an
......@@ -89,17 +89,17 @@ func (m *intArray) Connect(c *Conn, args []string) (VTab, error) {
func (m *intArray) DestroyModule() {
}
func (v *intArray) BestIndex() error {
func (m *intArray) BestIndex() error {
return nil
}
func (v *intArray) Disconnect() error {
func (m *intArray) Disconnect() error {
return nil
}
func (v *intArray) Destroy() error {
func (m *intArray) Destroy() error {
return nil
}
func (v *intArray) Open() (VTabCursor, error) {
return &intArrayVTabCursor{v, 0}, nil
func (m *intArray) Open() (VTabCursor, error) {
return &intArrayVTabCursor{m, 0}, nil
}
type intArrayVTabCursor struct {
......@@ -118,7 +118,7 @@ func (vc *intArrayVTabCursor) Next() error {
vc.i++
return nil
}
func (vc *intArrayVTabCursor) Eof() bool {
func (vc *intArrayVTabCursor) EOF() bool {
return vc.i >= len(vc.vTab.content)
}
func (vc *intArrayVTabCursor) Column(c *Context, col int) error {
......@@ -157,6 +157,6 @@ func (c *Conn) CreateIntArray(name string) (IntArray, error) {
// The array of integers bound must be unchanged for the duration of
// any query against the corresponding virtual table. If the integer
// array does change or is deallocated undefined behavior will result.
func (ia *intArray) Bind(elements []int64) {
ia.content = elements
func (m *intArray) Bind(elements []int64) {
m.content = elements
}
......@@ -15,6 +15,7 @@ import "C"
// (See http://www.sqlite.org/c3ref/c_limit_attached.html)
type Limit int32
// Run-time limit categories
const (
LimitLength Limit = C.SQLITE_LIMIT_LENGTH // The maximum size of any string or BLOB or table row, in bytes.
LimitColumn Limit = C.SQLITE_LIMIT_COLUMN
......
......@@ -228,6 +228,7 @@ func (s *Stmt) ColumnDeclaredType(index int) string {
// Affinity enumerates SQLite column type affinity
type Affinity string
// SQLite column type affinities
const (
Integral = Affinity("INTEGER") // Integer affinity
Real = Affinity("REAL")
......
......@@ -11,7 +11,7 @@ import (
"time"
)
// Adapted from https://code.google.com/p/vitess/source/browse/go/pools/roundrobin.go
// Pool adapted from https://code.google.com/p/vitess/source/browse/go/pools/roundrobin.go
type Pool struct {
mu sync.Mutex
available *sync.Cond
......@@ -144,7 +144,7 @@ func (p *Pool) IsClosed() bool {
return p.factory == nil
}
// Set capacity changes the capacity of the pool.
// SetCapacity changes the capacity of the pool.
// You can use it to expand or shrink.
func (p *Pool) SetCapacity(capacity int) {
p.mu.Lock()
......
......@@ -138,9 +138,9 @@ func (c *Conn) SetSynchronous(dbName string, mode int) error {
// FkViolation is the description of one foreign key constraint violation.
type FkViolation struct {
Table string
RowId int64
RowID int64
Parent string
FkId int
FkID int
}
// ForeignKeyCheck checks the database, or the table, for foreign key constraints that are violated
......@@ -172,7 +172,7 @@ func (c *Conn) ForeignKeyCheck(dbName, table string) ([]FkViolation, error) {
var violations = make([]FkViolation, 0, 20)
err = s.execQuery(func(s *Stmt) (err error) {
v := FkViolation{}
if err = s.Scan(&v.Table, &v.RowId, &v.Parent, &v.FkId); err != nil {
if err = s.Scan(&v.Table, &v.RowID, &v.Parent, &v.FkID); err != nil {
return
}
violations = append(violations, v)
......@@ -203,10 +203,10 @@ func (c *Conn) SetQueryOnly(dbName string, mode bool) error {
return c.FastExec(pragma(dbName, fmt.Sprintf("query_only=%t", mode)))
}
// ApplicationId queries the "Application ID" integer located into the database header.
// ApplicationID queries the "Application ID" integer located into the database header.
// Database name is optional (default is 'main').
// (See http://sqlite.org/pragma.html#pragma_application_id)
func (c *Conn) ApplicationId(dbName string) (int, error) {
func (c *Conn) ApplicationID(dbName string) (int, error) {
var id int
err := c.oneValue(pragma(dbName, "application_id"), &id)
if err != nil {
......@@ -215,10 +215,10 @@ func (c *Conn) ApplicationId(dbName string) (int, error) {
return id, nil
}
// SetApplicationId changes the "Application ID".
// SetApplicationID changes the "Application ID".
// Database name is optional (default is 'main').
// (See http://sqlite.org/pragma.html#pragma_application_id)
func (c *Conn) SetApplicationId(dbName string, id int) error {
func (c *Conn) SetApplicationID(dbName string, id int) error {
return c.FastExec(pragma(dbName, fmt.Sprintf("application_id=%d", id)))
}
......
......@@ -128,7 +128,7 @@ func TestQueryOnly(t *testing.T) {
assert.T(t, err != nil)
}
func TestApplicationId(t *testing.T) {
func TestApplicationID(t *testing.T) {
if VersionNumber() < 3007017 {
return
}
......@@ -136,18 +136,18 @@ func TestApplicationId(t *testing.T) {
db := open(t)
defer checkClose(db, t)
appId, err := db.ApplicationId("")
appID, err := db.ApplicationID("")
checkNoError(t, err, "error getting application Id: %s")
assert.Equalf(t, 0, appId, "got: %d; want: %d", appId, 0)
assert.Equalf(t, 0, appID, "got: %d; want: %d", appID, 0)
err = db.SetApplicationId("", 123)
err = db.SetApplicationID("", 123)
checkNoError(t, err, "error setting application Id: %s")
appId, err = db.ApplicationId("")
appID, err = db.ApplicationID("")
checkNoError(t, err, "error getting application Id: %s")
assert.Equalf(t, 123, appId, "got: %d; want: %d", appId, 123)
assert.Equalf(t, 123, appID, "got: %d; want: %d", appID, 123)
_, err = db.ApplicationId("bim")
_, err = db.ApplicationID("bim")
assert.T(t, err != nil)
}
......@@ -176,11 +176,11 @@ func TestForeignKeyCheck(t *testing.T) {
checkNoError(t, err, "error while checking FK: %s")
assert.Equal(t, 1, len(vs), "one FK violation expected")
v := vs[0]
assert.Equal(t, FkViolation{Table: "tree", RowId: 4, Parent: "tree", FkId: 0}, v)
assert.Equal(t, FkViolation{Table: "tree", RowID: 4, Parent: "tree", FkID: 0}, v)
fks, err := db.ForeignKeys("", "tree")
checkNoError(t, err, "error while loading FK: %s")
fk, ok := fks[v.FkId]
assert.Tf(t, ok, "no FK with id: %d", v.FkId)
fk, ok := fks[v.FkID]
assert.Tf(t, ok, "no FK with id: %d", v.FkID)
assert.Equal(t, &ForeignKey{Table: "tree", From: []string{"parentId"}, To: []string{"id"}}, fk)
mvs, err := db.ForeignKeyCheck("main", "tree")
......
......@@ -73,6 +73,7 @@ func (e Errno) Error() string {
return s
}
// SQLite result codes
const (
ErrError = Errno(C.SQLITE_ERROR) /* SQL error or missing database */
ErrInternal = Errno(C.SQLITE_INTERNAL) /* Internal logic error in SQLite */
......@@ -180,6 +181,7 @@ func VersionNumber() int32 {
// OpenFlag enumerates flags for file open operations
type OpenFlag int32
// Flags for file open operations
const (
OpenReadOnly OpenFlag = C.SQLITE_OPEN_READONLY
OpenReadWrite OpenFlag = C.SQLITE_OPEN_READWRITE
......@@ -386,6 +388,7 @@ func (c *Conn) GetAutocommit() bool {
// See Conn.BeginTransaction
type TransactionType uint8
// Transaction types
const (
Deferred TransactionType = 0
Immediate TransactionType = 1
......
......@@ -514,6 +514,7 @@ func (t Type) String() string {
return typeText[t]
}
// SQLite fundamental datatypes
const (
Integer = Type(C.SQLITE_INTEGER)
Float = Type(C.SQLITE_FLOAT)
......
......@@ -481,9 +481,9 @@ func TestInsertMisuse(t *testing.T) {
ois, err := db.Prepare("PRAGMA shrink_memory")
checkNoError(t, err, "prepare error: %s")
defer checkFinalize(ois, t)
rowId, err := ois.Insert()
rowID, err := ois.Insert()
checkNoError(t, err, "insert error: %s")
assert.Equal(t, int64(-1), rowId)
assert.Equal(t, int64(-1), rowID)
}
func TestScanValues(t *testing.T) {
......
......@@ -91,6 +91,7 @@ func (c *Conn) Profile(f Profiler, udp interface{}) {
// Auth enumerates Authorizer return codes
type Auth int32
// Authorizer return codes
const (
AuthOk Auth = C.SQLITE_OK
AuthDeny Auth = C.SQLITE_DENY
......@@ -100,6 +101,7 @@ const (
// Action enumerates Authorizer action codes
type Action int32
// Authorizer action codes
const (
CreateIndex Action = C.SQLITE_CREATE_INDEX
CreateTable Action = C.SQLITE_CREATE_TABLE
......@@ -299,6 +301,7 @@ func (c *Conn) ProgressHandler(f ProgressHandler, numOps int32, udp interface{})
// StmtStatus enumerates status parameters for prepared statements
type StmtStatus int32
// status counters for prepared statements
const (
StmtStatusFullScanStep StmtStatus = C.SQLITE_STMTSTATUS_FULLSCAN_STEP
StmtStatusSort StmtStatus = C.SQLITE_STMTSTATUS_SORT
......
......@@ -151,7 +151,7 @@ func goVNext(pCursor unsafe.Pointer) *C.char {
//export goVEof
func goVEof(pCursor unsafe.Pointer) C.int {
vtc := (*sqliteVTabCursor)(pCursor)
return btocint(vtc.vTabCursor.Eof())
return btocint(vtc.vTabCursor.EOF())
}
//export goVColumn
......@@ -218,7 +218,7 @@ type VTabCursor interface {
Close() error // See http://sqlite.org/vtab.html#xclose
Filter( /*idxNum int, idxStr string, int argc, sqlite3_value **argv*/ ) error // See http://sqlite.org/vtab.html#xfilter
Next() error // See http://sqlite.org/vtab.html#xnext
Eof() bool // See http://sqlite.org/vtab.html#xeof
EOF() bool // See http://sqlite.org/vtab.html#xeof
// col is zero-based so the first column is numbered 0
Column(c *Context, col int) error // See http://sqlite.org/vtab.html#xcolumn
Rowid() (int64, error) // See http://sqlite.org/vtab.html#xrowid
......
......@@ -81,8 +81,8 @@ func (vc *testVTabCursor) Next() error {
vc.index++
return nil
}
func (vc *testVTabCursor) Eof() bool {
//fmt.Printf("testVTabCursor.Eof: %v\n", vc)
func (vc *testVTabCursor) EOF() bool {
//fmt.Printf("testVTabCursor.EOF: %v\n", vc)
return vc.index >= len(vc.vTab.intarray)
}
func (vc *testVTabCursor) Column(c *Context, col int) error {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment