Commit 1febd6dc authored by gwenn's avatar gwenn

Golint comments and govet printf.

parent 7e0fdf5c
...@@ -36,7 +36,7 @@ func NewBackup(dst *Conn, dstDbName string, src *Conn, srcDbName string) (*Backu ...@@ -36,7 +36,7 @@ func NewBackup(dst *Conn, dstDbName string, src *Conn, srcDbName string) (*Backu
return &Backup{sb, dst, src}, nil return &Backup{sb, dst, src}, nil
} }
// Online backup // The Backup object records state information about an ongoing online backup operation.
// (See http://sqlite.org/c3ref/backup.html) // (See http://sqlite.org/c3ref/backup.html)
type Backup struct { type Backup struct {
sb *C.sqlite3_backup sb *C.sqlite3_backup
...@@ -56,7 +56,7 @@ func (b *Backup) Step(npage int) error { ...@@ -56,7 +56,7 @@ func (b *Backup) Step(npage int) error {
return Errno(rv) return Errno(rv)
} }
// Backup progression // BackupStatus reports backup progression
type BackupStatus struct { type BackupStatus struct {
Remaining int Remaining int
PageCount int PageCount int
......
...@@ -31,7 +31,7 @@ type BlobReadWriter struct { ...@@ -31,7 +31,7 @@ type BlobReadWriter struct {
BlobReader BlobReader
} }
// Zeroblobs are used to reserve space for a BLOB that is later written. // ZeroBlobLength is used to reserve space for a BLOB that is later written.
type ZeroBlobLength int type ZeroBlobLength int
// NewBlobReader opens a BLOB for incremental I/O in read-only mode. // NewBlobReader opens a BLOB for incremental I/O in read-only mode.
......
...@@ -41,6 +41,7 @@ func JulianDay(t time.Time) float64 { ...@@ -41,6 +41,7 @@ func JulianDay(t time.Time) float64 {
// UnixTime is an alias used to persist time as int64 (max precision is 1s and timezone is lost) (default) // UnixTime is an alias used to persist time as int64 (max precision is 1s and timezone is lost) (default)
type UnixTime time.Time type UnixTime time.Time
// Scan implements the database/sql/Scanner interface.
func (t *UnixTime) Scan(src interface{}) error { func (t *UnixTime) Scan(src interface{}) error {
if src == nil { if src == nil {
//t = nil //t = nil
...@@ -51,6 +52,8 @@ func (t *UnixTime) Scan(src interface{}) error { ...@@ -51,6 +52,8 @@ func (t *UnixTime) Scan(src interface{}) error {
} }
return fmt.Errorf("Unsupported UnixTime src: %T", src) return fmt.Errorf("Unsupported UnixTime src: %T", src)
} }
// Value implements the database/sql/driver/Valuer interface
func (t UnixTime) Value() (driver.Value, error) { func (t UnixTime) Value() (driver.Value, error) {
if (time.Time)(t).IsZero() { if (time.Time)(t).IsZero() {
return nil, nil return nil, nil
...@@ -61,6 +64,7 @@ func (t UnixTime) Value() (driver.Value, error) { ...@@ -61,6 +64,7 @@ func (t UnixTime) Value() (driver.Value, error) {
// JulianTime is an alias used to persist time as float64 (max precision is 1s and timezone is lost) // JulianTime is an alias used to persist time as float64 (max precision is 1s and timezone is lost)
type JulianTime time.Time type JulianTime time.Time
// Scan implements the database/sql/Scanner interface.
func (t *JulianTime) Scan(src interface{}) error { func (t *JulianTime) Scan(src interface{}) error {
if src == nil { if src == nil {
//t = nil //t = nil
...@@ -71,6 +75,8 @@ func (t *JulianTime) Scan(src interface{}) error { ...@@ -71,6 +75,8 @@ func (t *JulianTime) Scan(src interface{}) error {
} }
return fmt.Errorf("Unsupported JulianTime src: %T", src) return fmt.Errorf("Unsupported JulianTime src: %T", src)
} }
// Value implements the database/sql/driver/Valuer interface
func (t JulianTime) Value() (driver.Value, error) { func (t JulianTime) Value() (driver.Value, error) {
if (time.Time)(t).IsZero() { if (time.Time)(t).IsZero() {
return nil, nil return nil, nil
...@@ -81,6 +87,7 @@ func (t JulianTime) Value() (driver.Value, error) { ...@@ -81,6 +87,7 @@ func (t JulianTime) Value() (driver.Value, error) {
// TimeStamp is an alias used to persist time as '2006-01-02T15:04:05.999Z07:00' string // TimeStamp is an alias used to persist time as '2006-01-02T15:04:05.999Z07:00' string
type TimeStamp time.Time type TimeStamp time.Time
// Scan implements the database/sql/Scanner interface.
func (t *TimeStamp) Scan(src interface{}) error { func (t *TimeStamp) Scan(src interface{}) error {
if src == nil { if src == nil {
//t = nil //t = nil
...@@ -95,6 +102,8 @@ func (t *TimeStamp) Scan(src interface{}) error { ...@@ -95,6 +102,8 @@ func (t *TimeStamp) Scan(src interface{}) error {
} }
return fmt.Errorf("Unsupported TimeStamp src: %T", src) return fmt.Errorf("Unsupported TimeStamp src: %T", src)
} }
// Value implements the database/sql/driver/Valuer interface
func (t TimeStamp) Value() (driver.Value, error) { func (t TimeStamp) Value() (driver.Value, error) {
if (time.Time)(t).IsZero() { if (time.Time)(t).IsZero() {
return nil, nil return nil, nil
......
...@@ -76,14 +76,14 @@ type FunctionContext struct { ...@@ -76,14 +76,14 @@ type FunctionContext struct {
argv **C.sqlite3_value argv **C.sqlite3_value
} }
// Context associated to scalar function // ScalarContext is used to represent context associated to scalar function
type ScalarContext struct { type ScalarContext struct {
FunctionContext FunctionContext
ad map[int]interface{} // Function Auxiliary Data ad map[int]interface{} // Function Auxiliary Data
udf *sqliteFunction udf *sqliteFunction
} }
// Context associated to aggregate function // AggregateContext is used to represent context associated to aggregate function
type AggregateContext struct { type AggregateContext struct {
FunctionContext FunctionContext
Aggregate interface{} Aggregate interface{}
...@@ -320,9 +320,16 @@ func (c *FunctionContext) Value(i int) (value interface{}) { ...@@ -320,9 +320,16 @@ func (c *FunctionContext) Value(i int) (value interface{}) {
return return
} }
// ScalarFunction is the expected signature of scalar function implemented in Go
type ScalarFunction func(ctx *ScalarContext, nArg int) type ScalarFunction func(ctx *ScalarContext, nArg int)
// StepFunction is the expected signature of step function implemented in Go
type StepFunction func(ctx *AggregateContext, nArg int) type StepFunction func(ctx *AggregateContext, nArg int)
// FinalFunction is the expected signature of final function implemented in Go
type FinalFunction func(ctx *AggregateContext) type FinalFunction func(ctx *AggregateContext)
// DestroyFunctionData is the expected signature of function used to finalize user data.
type DestroyFunctionData func(pApp interface{}) type DestroyFunctionData func(pApp interface{})
type sqliteFunction struct { type sqliteFunction struct {
...@@ -413,7 +420,8 @@ func goXDestroy(pApp unsafe.Pointer) { ...@@ -413,7 +420,8 @@ func goXDestroy(pApp unsafe.Pointer) {
// CreateScalarFunction creates or redefines SQL scalar functions. // CreateScalarFunction creates or redefines SQL scalar functions.
// TODO Make possible to specify the preferred encoding // TODO Make possible to specify the preferred encoding
// (See http://sqlite.org/c3ref/create_function.html) // (See http://sqlite.org/c3ref/create_function.html)
func (c *Conn) CreateScalarFunction(functionName string, nArg int, pApp interface{}, f ScalarFunction, d DestroyFunctionData) error { func (c *Conn) CreateScalarFunction(functionName string, nArg int, pApp interface{},
f ScalarFunction, d DestroyFunctionData) error {
fname := C.CString(functionName) fname := C.CString(functionName)
defer C.free(unsafe.Pointer(fname)) defer C.free(unsafe.Pointer(fname))
if f == nil { if f == nil {
......
...@@ -18,6 +18,7 @@ import ( ...@@ -18,6 +18,7 @@ import (
"unsafe" "unsafe"
) )
// CommitHook is the callback function signature.
// If the callback on a commit hook function returns true, then the commit is converted into a rollback. // If the callback on a commit hook function returns true, then the commit is converted into a rollback.
type CommitHook func(udp interface{}) bool type CommitHook func(udp interface{}) bool
...@@ -45,6 +46,7 @@ func (c *Conn) CommitHook(f CommitHook, udp interface{}) { ...@@ -45,6 +46,7 @@ func (c *Conn) CommitHook(f CommitHook, udp interface{}) {
C.goSqlite3CommitHook(c.db, unsafe.Pointer(c.commitHook)) C.goSqlite3CommitHook(c.db, unsafe.Pointer(c.commitHook))
} }
// RollbackHook is the callback function signature.
type RollbackHook func(udp interface{}) type RollbackHook func(udp interface{})
type sqliteRollbackHook struct { type sqliteRollbackHook struct {
...@@ -71,6 +73,7 @@ func (c *Conn) RollbackHook(f RollbackHook, udp interface{}) { ...@@ -71,6 +73,7 @@ func (c *Conn) RollbackHook(f RollbackHook, udp interface{}) {
C.goSqlite3RollbackHook(c.db, unsafe.Pointer(c.rollbackHook)) C.goSqlite3RollbackHook(c.db, unsafe.Pointer(c.rollbackHook))
} }
// 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 { type sqliteUpdateHook struct {
...@@ -84,7 +87,8 @@ func goXUpdateHook(udp unsafe.Pointer, action int, dbName, tableName *C.char, ro ...@@ -84,7 +87,8 @@ func goXUpdateHook(udp unsafe.Pointer, action int, dbName, tableName *C.char, ro
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, inserted or deleted using this database connection. // UpdateHook registers a callback to be invoked each time a row is updated,
// inserted or deleted using this database connection.
// (See http://sqlite.org/c3ref/update_hook.html) // (See http://sqlite.org/c3ref/update_hook.html)
func (c *Conn) UpdateHook(f UpdateHook, udp interface{}) { func (c *Conn) UpdateHook(f UpdateHook, udp interface{}) {
if f == nil { if f == nil {
......
...@@ -89,6 +89,7 @@ func (c *Conn) Tables(dbName string) ([]string, error) { ...@@ -89,6 +89,7 @@ func (c *Conn) Tables(dbName string) ([]string, error) {
return tables, nil return tables, nil
} }
// Column is the description of one table's column
// See Conn.Columns/IndexColumns // See Conn.Columns/IndexColumns
type Column struct { type Column struct {
Cid int Cid int
...@@ -180,13 +181,15 @@ func (s *Stmt) ColumnOriginName(index int) string { ...@@ -180,13 +181,15 @@ func (s *Stmt) ColumnOriginName(index int) string {
return C.GoString(C.sqlite3_column_origin_name(s.stmt, C.int(index))) return C.GoString(C.sqlite3_column_origin_name(s.stmt, C.int(index)))
} }
// ColumnDeclaredType returns the declared type of the table column of a particular result column in SELECT statement. If the result column is an expression or subquery, then a NULL pointer is returned. // ColumnDeclaredType returns the declared type of the table column of a particular result column in SELECT statement.
// If the result column is an expression or subquery, then a NULL pointer is returned.
// The left-most column is column 0. // The left-most column is column 0.
// (See http://www.sqlite.org/c3ref/column_decltype.html) // (See http://www.sqlite.org/c3ref/column_decltype.html)
func (s *Stmt) ColumnDeclaredType(index int) string { func (s *Stmt) ColumnDeclaredType(index int) string {
return C.GoString(C.sqlite3_column_decltype(s.stmt, C.int(index))) return C.GoString(C.sqlite3_column_decltype(s.stmt, C.int(index)))
} }
// ForeignKey is the description of one table's foreign key
// See Conn.ForeignKeys // See Conn.ForeignKeys
type ForeignKey struct { type ForeignKey struct {
Table string Table string
...@@ -231,6 +234,7 @@ func (c *Conn) ForeignKeys(dbName, table string) (map[int]*ForeignKey, error) { ...@@ -231,6 +234,7 @@ func (c *Conn) ForeignKeys(dbName, table string) (map[int]*ForeignKey, error) {
return fks, nil return fks, nil
} }
// Index is the description of one table's index
// See Conn.Indexes // See Conn.Indexes
type Index struct { type Index struct {
Name string Name string
......
...@@ -135,6 +135,7 @@ func (c *Conn) SetSynchronous(dbName string, mode int) error { ...@@ -135,6 +135,7 @@ func (c *Conn) SetSynchronous(dbName string, mode int) error {
return c.exec(pragma(dbName, fmt.Sprintf("synchronous=%d", mode))) return c.exec(pragma(dbName, fmt.Sprintf("synchronous=%d", mode)))
} }
// FkViolation is the description of one foreign key constraint violation.
type FkViolation struct { type FkViolation struct {
Table string Table string
Rowid int64 Rowid int64
......
...@@ -229,7 +229,7 @@ func OpenVfs(filename string, vfsname string, flags ...OpenFlag) (*Conn, error) ...@@ -229,7 +229,7 @@ func OpenVfs(filename string, vfsname string, flags ...OpenFlag) (*Conn, error)
} }
func authorizer(d interface{}, action Action, arg1, arg2, dbName, triggerName string) Auth { func authorizer(d interface{}, action Action, arg1, arg2, dbName, triggerName string) Auth {
fmt.Fprintf(os.Stderr, "%p: %s, %s, %s, %s, %s\n", d, action, arg1, arg2, dbName, triggerName) fmt.Fprintf(os.Stderr, "%p: %v, %s, %s, %s, %s\n", d, action, arg1, arg2, dbName, triggerName)
return AuthOk return AuthOk
} }
......
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