Skip to content

Commit

Permalink
bump minimum go version to 1.8, add go 1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
maddyblue committed Mar 20, 2018
1 parent b200422 commit b75c132
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 36 deletions.
12 changes: 0 additions & 12 deletions .travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@ postgresql_uninstall() {
}

megacheck_install() {
# Megacheck is Go 1.6+, so skip if Go 1.5.
if [[ "$(go version)" =~ "go1.5" ]]
then
echo "megacheck not supported, skipping installation"
return 0
fi
# Lock megacheck version at $MEGACHECK_VERSION to prevent spontaneous
# new error messages in old code.
go get -d honnef.co/go/tools/...
Expand All @@ -86,12 +80,6 @@ megacheck_install() {
}

golint_install() {
# Golint is Go 1.6+, so skip if Go 1.5.
if [[ "$(go version)" =~ "go1.5" ]]
then
echo "golint not supported, skipping installation"
return 0
fi
go get github.com/golang/lint/golint
}

Expand Down
15 changes: 4 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
language: go

go:
- 1.6.x
- 1.7.x
- 1.8.x
- 1.9.x
- 1.10.x
- master

sudo: true
Expand All @@ -15,7 +14,7 @@ env:
- PQGOSSLTESTS=1
- PQSSLCERTTEST_PATH=$PWD/certs
- PGHOST=127.0.0.1
- MEGACHECK_VERSION=2017.2.1
- MEGACHECK_VERSION=2017.2.2
matrix:
- PGVERSION=10
- PGVERSION=9.6
Expand Down Expand Up @@ -45,13 +44,7 @@ script:
- >
goimports -d -e $(find -name '*.go') | awk '{ print } END { exit NR == 0 ? 0 : 1 }'
- go vet ./...
# For compatibility with Go 1.5, launch only if megacheck is present.
- >
which megacheck > /dev/null && megacheck -go 1.5 ./...
|| echo 'megacheck is not supported, skipping check'
# For compatibility with Go 1.5, launch only if golint is present.
- >
which golint > /dev/null && golint ./...
|| echo 'golint is not supported, skipping check'
- megacheck -go 1.8 ./...
- golint ./...
- PQTEST_BINARY_PARAMETERS=no go test -race -v ./...
- PQTEST_BINARY_PARAMETERS=yes go test -race -v ./...
5 changes: 3 additions & 2 deletions bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package pq
import (
"bufio"
"bytes"
"context"
"database/sql"
"database/sql/driver"
"io"
Expand Down Expand Up @@ -156,7 +157,7 @@ func benchMockQuery(b *testing.B, c *conn, query string) {
b.Fatal(err)
}
defer stmt.Close()
rows, err := stmt.Query(nil)
rows, err := stmt.(driver.StmtQueryContext).QueryContext(context.Background(), nil)
if err != nil {
b.Fatal(err)
}
Expand Down Expand Up @@ -266,7 +267,7 @@ func BenchmarkMockPreparedSelectSeries(b *testing.B) {
}

func benchPreparedMockQuery(b *testing.B, c *conn, stmt driver.Stmt) {
rows, err := stmt.Query(nil)
rows, err := stmt.(driver.StmtQueryContext).QueryContext(context.Background(), nil)
if err != nil {
b.Fatal(err)
}
Expand Down
9 changes: 5 additions & 4 deletions conn_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package pq

import (
"context"
"database/sql"
"database/sql/driver"
"fmt"
Expand Down Expand Up @@ -1263,8 +1264,8 @@ func TestParseComplete(t *testing.T) {

// Test interface conformance.
var (
_ driver.Execer = (*conn)(nil)
_ driver.Queryer = (*conn)(nil)
_ driver.ExecerContext = (*conn)(nil)
_ driver.QueryerContext = (*conn)(nil)
)

func TestNullAfterNonNull(t *testing.T) {
Expand Down Expand Up @@ -1609,10 +1610,10 @@ func TestRowsResultTag(t *testing.T) {
t.Fatal(err)
}
defer conn.Close()
q := conn.(driver.Queryer)
q := conn.(driver.QueryerContext)

for _, test := range tests {
if rows, err := q.Query(test.query, nil); err != nil {
if rows, err := q.QueryContext(context.Background(), test.query, nil); err != nil {
t.Fatalf("%s: %s", test.query, err)
} else {
r := rows.(ResultTag)
Expand Down
15 changes: 10 additions & 5 deletions copy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"database/sql"
"database/sql/driver"
"net"
"strings"
"testing"
)
Expand Down Expand Up @@ -400,15 +401,19 @@ func TestCopyRespLoopConnectionError(t *testing.T) {
if err == nil {
t.Fatalf("expected error")
}
pge, ok := err.(*Error)
if !ok {
switch pge := err.(type) {
case *Error:
if pge.Code.Name() != "admin_shutdown" {
t.Fatalf("expected admin_shutdown, got %s", pge.Code.Name())
}
case *net.OpError:
// ignore
default:
if err == driver.ErrBadConn {
// likely an EPIPE
} else {
t.Fatalf("expected *pq.Error or driver.ErrBadConn, got %+#v", err)
t.Fatalf("unexpected error, got %+#v", err)
}
} else if pge.Code.Name() != "admin_shutdown" {
t.Fatalf("expected admin_shutdown, got %s", pge.Code.Name())
}

_ = stmt.Close()
Expand Down
4 changes: 3 additions & 1 deletion go18_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ func TestContextCancelBegin(t *testing.T) {
cancel()
if err != nil {
t.Fatal(err)
} else if err := tx.Rollback(); err != nil && err != sql.ErrTxDone {
} else if err := tx.Rollback(); err != nil &&
err.Error() != "pq: canceling statement due to user request" &&
err != sql.ErrTxDone {
t.Fatal(err)
}
}()
Expand Down
2 changes: 1 addition & 1 deletion notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ func (l *Listener) listenerConnLoop() {
}
l.emitEvent(ListenerEventDisconnected, err)

time.Sleep(nextReconnect.Sub(time.Now()))
time.Sleep(time.Until(nextReconnect))
}
}

Expand Down

0 comments on commit b75c132

Please sign in to comment.