Commit 88bba055 authored by gwenn's avatar gwenn

Go lint and vet.

parent 60ba4c36
......@@ -78,7 +78,7 @@ func TestIntArrayModule(t *testing.T) {
checkNoError(t, p3.Drop(), "%s")
}
const INTARRAY_SIZE = 100
const IntArraySize = 100
func BenchmarkNoIntArray(b *testing.B) {
b.StopTimer()
......@@ -87,14 +87,14 @@ func BenchmarkNoIntArray(b *testing.B) {
defer db.Close()
panicOnError(b, db.Exec("CREATE TABLE rand (r INT)"))
values := rand.Perm(INTARRAY_SIZE)
values := rand.Perm(IntArraySize)
for _, v := range values {
panicOnError(b, db.Exec("INSERT INTO rand (r) VALUES (?)", v))
}
b.StartTimer()
for i := 0; i < b.N; i++ {
l := rand.Intn(INTARRAY_SIZE-1) + 1 // at least one value
l := rand.Intn(IntArraySize-1) + 1 // at least one value
sql := fmt.Sprintf("SELECT * FROM rand WHERE r IN (?%s)", strings.Repeat(", ?", l-1))
s, err := db.Prepare(sql)
panicOnError(b, err)
......@@ -122,7 +122,7 @@ func BenchmarkIntArray(b *testing.B) {
defer db.Close()
panicOnError(b, db.Exec("CREATE TABLE rand (r INT)"))
perms := rand.Perm(INTARRAY_SIZE)
perms := rand.Perm(IntArraySize)
values := make([]int64, len(perms))
for i, v := range perms {
panicOnError(b, db.Exec("INSERT INTO rand (r) VALUES (?)", v))
......@@ -139,7 +139,7 @@ func BenchmarkIntArray(b *testing.B) {
defer s.Finalize()
for i := 0; i < b.N; i++ {
l := rand.Intn(INTARRAY_SIZE-1) + 1 // at least one value
l := rand.Intn(IntArraySize-1) + 1 // at least one value
p.Bind(values[0:l])
nr := 0
err = s.Select(func(s *Stmt) error {
......
......@@ -359,11 +359,11 @@ func (c *Conn) Select(query string, rowCallbackHandler func(s *Stmt) error, args
return s.Select(rowCallbackHandler, args...)
}
// SelectById helps executing SELECT statement that is expected to return only one row.
// SelectByID helps executing SELECT statement that is expected to return only one row.
// Args are for scanning (not binding).
// Returns false if there is no matching row.
// No check is done to ensure that no more than one row is returned by the statement.
func (c *Conn) SelectById(query string, id interface{}, args ...interface{}) (found bool, err error) {
func (c *Conn) SelectByID(query string, id interface{}, args ...interface{}) (found bool, err error) {
s, err := c.Prepare(query, id)
if err != nil {
return false, err
......@@ -470,7 +470,6 @@ func (c *Conn) BeginTransaction(t TransactionType) error {
return c.FastExec("BEGIN EXCLUSIVE")
}
panic(fmt.Sprintf("Unsupported transaction type: '%#v'", t))
return nil // Go 1.1 unreachable code
}
// Commit commits transaction
......
......@@ -45,7 +45,7 @@ func btocint(b bool) C.int {
return 0
}
func cstring(s string) (*C.char, C.int) {
cs := *(*reflect.StringHeader)(unsafe.Pointer(&s))
cs := (*reflect.StringHeader)(unsafe.Pointer(&s))
return (*C.char)(unsafe.Pointer(cs.Data)), C.int(cs.Len)
}
......
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