Skip to content

Commit b75c132

Browse files
committed
bump minimum go version to 1.8, add go 1.10
1 parent b200422 commit b75c132

File tree

7 files changed

+26
-36
lines changed

7 files changed

+26
-36
lines changed

.travis.sh

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,6 @@ postgresql_uninstall() {
7171
}
7272

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

8882
golint_install() {
89-
# Golint is Go 1.6+, so skip if Go 1.5.
90-
if [[ "$(go version)" =~ "go1.5" ]]
91-
then
92-
echo "golint not supported, skipping installation"
93-
return 0
94-
fi
9583
go get github.com/golang/lint/golint
9684
}
9785

.travis.yml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
language: go
22

33
go:
4-
- 1.6.x
5-
- 1.7.x
64
- 1.8.x
75
- 1.9.x
6+
- 1.10.x
87
- master
98

109
sudo: true
@@ -15,7 +14,7 @@ env:
1514
- PQGOSSLTESTS=1
1615
- PQSSLCERTTEST_PATH=$PWD/certs
1716
- PGHOST=127.0.0.1
18-
- MEGACHECK_VERSION=2017.2.1
17+
- MEGACHECK_VERSION=2017.2.2
1918
matrix:
2019
- PGVERSION=10
2120
- PGVERSION=9.6
@@ -45,13 +44,7 @@ script:
4544
- >
4645
goimports -d -e $(find -name '*.go') | awk '{ print } END { exit NR == 0 ? 0 : 1 }'
4746
- go vet ./...
48-
# For compatibility with Go 1.5, launch only if megacheck is present.
49-
- >
50-
which megacheck > /dev/null && megacheck -go 1.5 ./...
51-
|| echo 'megacheck is not supported, skipping check'
52-
# For compatibility with Go 1.5, launch only if golint is present.
53-
- >
54-
which golint > /dev/null && golint ./...
55-
|| echo 'golint is not supported, skipping check'
47+
- megacheck -go 1.8 ./...
48+
- golint ./...
5649
- PQTEST_BINARY_PARAMETERS=no go test -race -v ./...
5750
- PQTEST_BINARY_PARAMETERS=yes go test -race -v ./...

bench_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package pq
55
import (
66
"bufio"
77
"bytes"
8+
"context"
89
"database/sql"
910
"database/sql/driver"
1011
"io"
@@ -156,7 +157,7 @@ func benchMockQuery(b *testing.B, c *conn, query string) {
156157
b.Fatal(err)
157158
}
158159
defer stmt.Close()
159-
rows, err := stmt.Query(nil)
160+
rows, err := stmt.(driver.StmtQueryContext).QueryContext(context.Background(), nil)
160161
if err != nil {
161162
b.Fatal(err)
162163
}
@@ -266,7 +267,7 @@ func BenchmarkMockPreparedSelectSeries(b *testing.B) {
266267
}
267268

268269
func benchPreparedMockQuery(b *testing.B, c *conn, stmt driver.Stmt) {
269-
rows, err := stmt.Query(nil)
270+
rows, err := stmt.(driver.StmtQueryContext).QueryContext(context.Background(), nil)
270271
if err != nil {
271272
b.Fatal(err)
272273
}

conn_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package pq
22

33
import (
4+
"context"
45
"database/sql"
56
"database/sql/driver"
67
"fmt"
@@ -1263,8 +1264,8 @@ func TestParseComplete(t *testing.T) {
12631264

12641265
// Test interface conformance.
12651266
var (
1266-
_ driver.Execer = (*conn)(nil)
1267-
_ driver.Queryer = (*conn)(nil)
1267+
_ driver.ExecerContext = (*conn)(nil)
1268+
_ driver.QueryerContext = (*conn)(nil)
12681269
)
12691270

12701271
func TestNullAfterNonNull(t *testing.T) {
@@ -1609,10 +1610,10 @@ func TestRowsResultTag(t *testing.T) {
16091610
t.Fatal(err)
16101611
}
16111612
defer conn.Close()
1612-
q := conn.(driver.Queryer)
1613+
q := conn.(driver.QueryerContext)
16131614

16141615
for _, test := range tests {
1615-
if rows, err := q.Query(test.query, nil); err != nil {
1616+
if rows, err := q.QueryContext(context.Background(), test.query, nil); err != nil {
16161617
t.Fatalf("%s: %s", test.query, err)
16171618
} else {
16181619
r := rows.(ResultTag)

copy_test.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"database/sql"
66
"database/sql/driver"
7+
"net"
78
"strings"
89
"testing"
910
)
@@ -400,15 +401,19 @@ func TestCopyRespLoopConnectionError(t *testing.T) {
400401
if err == nil {
401402
t.Fatalf("expected error")
402403
}
403-
pge, ok := err.(*Error)
404-
if !ok {
404+
switch pge := err.(type) {
405+
case *Error:
406+
if pge.Code.Name() != "admin_shutdown" {
407+
t.Fatalf("expected admin_shutdown, got %s", pge.Code.Name())
408+
}
409+
case *net.OpError:
410+
// ignore
411+
default:
405412
if err == driver.ErrBadConn {
406413
// likely an EPIPE
407414
} else {
408-
t.Fatalf("expected *pq.Error or driver.ErrBadConn, got %+#v", err)
415+
t.Fatalf("unexpected error, got %+#v", err)
409416
}
410-
} else if pge.Code.Name() != "admin_shutdown" {
411-
t.Fatalf("expected admin_shutdown, got %s", pge.Code.Name())
412417
}
413418

414419
_ = stmt.Close()

go18_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,9 @@ func TestContextCancelBegin(t *testing.T) {
228228
cancel()
229229
if err != nil {
230230
t.Fatal(err)
231-
} else if err := tx.Rollback(); err != nil && err != sql.ErrTxDone {
231+
} else if err := tx.Rollback(); err != nil &&
232+
err.Error() != "pq: canceling statement due to user request" &&
233+
err != sql.ErrTxDone {
232234
t.Fatal(err)
233235
}
234236
}()

notify.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ func (l *Listener) listenerConnLoop() {
784784
}
785785
l.emitEvent(ListenerEventDisconnected, err)
786786

787-
time.Sleep(nextReconnect.Sub(time.Now()))
787+
time.Sleep(time.Until(nextReconnect))
788788
}
789789
}
790790

0 commit comments

Comments
 (0)