forked from mirror/go-sqlcipher
go vet && golint
This commit is contained in:
parent
cde7293c72
commit
15491aeb9c
|
@ -1,3 +1,8 @@
|
|||
// Copyright (C) 2014 Yasuhiro Matsumoto <mattn.jp@gmail.com>.
|
||||
//
|
||||
// Use of this source code is governed by an MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build go1.8
|
||||
|
||||
package sqlite3
|
||||
|
@ -6,7 +11,7 @@ import (
|
|||
"database/sql/driver"
|
||||
"errors"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
"context"
|
||||
)
|
||||
|
||||
// Ping implement Pinger.
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
//
|
||||
// Use of this source code is governed by an MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build go1.8
|
||||
|
||||
package sqlite3
|
||||
|
|
|
@ -207,12 +207,12 @@ func TestUpdate(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal("Failed to update record:", err)
|
||||
}
|
||||
lastId, err := res.LastInsertId()
|
||||
lastID, err := res.LastInsertId()
|
||||
if err != nil {
|
||||
t.Fatal("Failed to get LastInsertId:", err)
|
||||
}
|
||||
if expected != lastId {
|
||||
t.Errorf("Expected %q for last Id, but %q:", expected, lastId)
|
||||
if expected != lastID {
|
||||
t.Errorf("Expected %q for last Id, but %q:", expected, lastID)
|
||||
}
|
||||
affected, _ = res.RowsAffected()
|
||||
if err != nil {
|
||||
|
@ -272,12 +272,12 @@ func TestDelete(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal("Failed to delete record:", err)
|
||||
}
|
||||
lastId, err := res.LastInsertId()
|
||||
lastID, err := res.LastInsertId()
|
||||
if err != nil {
|
||||
t.Fatal("Failed to get LastInsertId:", err)
|
||||
}
|
||||
if expected != lastId {
|
||||
t.Errorf("Expected %q for last Id, but %q:", expected, lastId)
|
||||
if expected != lastID {
|
||||
t.Errorf("Expected %q for last Id, but %q:", expected, lastID)
|
||||
}
|
||||
affected, err = res.RowsAffected()
|
||||
if err != nil {
|
||||
|
@ -1070,12 +1070,12 @@ func TestDateTimeNow(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestFunctionRegistration(t *testing.T) {
|
||||
addi_8_16_32 := func(a int8, b int16) int32 { return int32(a) + int32(b) }
|
||||
addi_64 := func(a, b int64) int64 { return a + b }
|
||||
addu_8_16_32 := func(a uint8, b uint16) uint32 { return uint32(a) + uint32(b) }
|
||||
addu_64 := func(a, b uint64) uint64 { return a + b }
|
||||
addi8_16_32 := func(a int8, b int16) int32 { return int32(a) + int32(b) }
|
||||
addi64 := func(a, b int64) int64 { return a + b }
|
||||
addu8_16_32 := func(a uint8, b uint16) uint32 { return uint32(a) + uint32(b) }
|
||||
addu64 := func(a, b uint64) uint64 { return a + b }
|
||||
addiu := func(a int, b uint) int64 { return int64(a) + int64(b) }
|
||||
addf_32_64 := func(a float32, b float64) float64 { return float64(a) + b }
|
||||
addf32_64 := func(a float32, b float64) float64 { return float64(a) + b }
|
||||
not := func(a bool) bool { return !a }
|
||||
regex := func(re, s string) (bool, error) {
|
||||
return regexp.MatchString(re, s)
|
||||
|
@ -1107,22 +1107,22 @@ func TestFunctionRegistration(t *testing.T) {
|
|||
|
||||
sql.Register("sqlite3_FunctionRegistration", &SQLiteDriver{
|
||||
ConnectHook: func(conn *SQLiteConn) error {
|
||||
if err := conn.RegisterFunc("addi_8_16_32", addi_8_16_32, true); err != nil {
|
||||
if err := conn.RegisterFunc("addi8_16_32", addi8_16_32, true); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := conn.RegisterFunc("addi_64", addi_64, true); err != nil {
|
||||
if err := conn.RegisterFunc("addi64", addi64, true); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := conn.RegisterFunc("addu_8_16_32", addu_8_16_32, true); err != nil {
|
||||
if err := conn.RegisterFunc("addu8_16_32", addu8_16_32, true); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := conn.RegisterFunc("addu_64", addu_64, true); err != nil {
|
||||
if err := conn.RegisterFunc("addu64", addu64, true); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := conn.RegisterFunc("addiu", addiu, true); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := conn.RegisterFunc("addf_32_64", addf_32_64, true); err != nil {
|
||||
if err := conn.RegisterFunc("addf32_64", addf32_64, true); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := conn.RegisterFunc("not", not, true); err != nil {
|
||||
|
@ -1153,12 +1153,12 @@ func TestFunctionRegistration(t *testing.T) {
|
|||
query string
|
||||
expected interface{}
|
||||
}{
|
||||
{"SELECT addi_8_16_32(1,2)", int32(3)},
|
||||
{"SELECT addi_64(1,2)", int64(3)},
|
||||
{"SELECT addu_8_16_32(1,2)", uint32(3)},
|
||||
{"SELECT addu_64(1,2)", uint64(3)},
|
||||
{"SELECT addi8_16_32(1,2)", int32(3)},
|
||||
{"SELECT addi64(1,2)", int64(3)},
|
||||
{"SELECT addu8_16_32(1,2)", uint32(3)},
|
||||
{"SELECT addu64(1,2)", uint64(3)},
|
||||
{"SELECT addiu(1,2)", int64(3)},
|
||||
{"SELECT addf_32_64(1.5,1.5)", float64(3)},
|
||||
{"SELECT addf32_64(1.5,1.5)", float64(3)},
|
||||
{"SELECT not(1)", false},
|
||||
{"SELECT not(0)", true},
|
||||
{`SELECT regex("^foo.*", "foobar")`, true},
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
// ColumnTypeDatabaseTypeName implement RowsColumnTypeDatabaseTypeName.
|
||||
func (rc *SQLiteRows) ColumnTypeDatabaseTypeName(i int) string {
|
||||
return C.GoString(C.sqlite3_column_decltype(rc.s.s, C.int(i)))
|
||||
}
|
||||
|
@ -27,10 +28,12 @@ func (rc *SQLiteRows) ColumnTypePrecisionScale(index int) (precision, scale int6
|
|||
}
|
||||
*/
|
||||
|
||||
// ColumnTypeNullable implement RowsColumnTypeNullable.
|
||||
func (rc *SQLiteRows) ColumnTypeNullable(i int) (nullable, ok bool) {
|
||||
return true, true
|
||||
}
|
||||
|
||||
// ColumnTypeScanType implement RowsColumnTypeScanType.
|
||||
func (rc *SQLiteRows) ColumnTypeScanType(i int) reflect.Type {
|
||||
switch C.sqlite3_column_type(rc.s.s, C.int(i)) {
|
||||
case C.SQLITE_INTEGER:
|
||||
|
|
Loading…
Reference in New Issue