drop support for Go 1.15

This commit is contained in:
Marten Seemann
2021-08-05 10:28:43 +02:00
parent 761c0fabd6
commit 68e468a3bc
30 changed files with 93 additions and 209 deletions

View File

@@ -44,9 +44,17 @@ func (e *TransportError) Error() string {
return str + ": " + msg
}
func (e *TransportError) Is(target error) bool {
return target == net.ErrClosed
}
// An ApplicationErrorCode is an application-defined error code.
type ApplicationErrorCode uint64
func (e *ApplicationError) Is(target error) bool {
return target == net.ErrClosed
}
// A StreamErrorCode is an error code used to cancel streams.
type StreamErrorCode uint64
@@ -69,17 +77,19 @@ type IdleTimeoutError struct{}
var _ error = &IdleTimeoutError{}
func (e *IdleTimeoutError) Timeout() bool { return true }
func (e *IdleTimeoutError) Temporary() bool { return false }
func (e *IdleTimeoutError) Error() string { return "timeout: no recent network activity" }
func (e *IdleTimeoutError) Timeout() bool { return true }
func (e *IdleTimeoutError) Temporary() bool { return false }
func (e *IdleTimeoutError) Error() string { return "timeout: no recent network activity" }
func (e *IdleTimeoutError) Is(target error) bool { return target == net.ErrClosed }
type HandshakeTimeoutError struct{}
var _ error = &HandshakeTimeoutError{}
func (e *HandshakeTimeoutError) Timeout() bool { return true }
func (e *HandshakeTimeoutError) Temporary() bool { return false }
func (e *HandshakeTimeoutError) Error() string { return "timeout: handshake did not complete in time" }
func (e *HandshakeTimeoutError) Timeout() bool { return true }
func (e *HandshakeTimeoutError) Temporary() bool { return false }
func (e *HandshakeTimeoutError) Error() string { return "timeout: handshake did not complete in time" }
func (e *HandshakeTimeoutError) Is(target error) bool { return target == net.ErrClosed }
// A VersionNegotiationError occurs when the client and the server can't agree on a QUIC version.
type VersionNegotiationError struct {
@@ -91,6 +101,10 @@ func (e *VersionNegotiationError) Error() string {
return fmt.Sprintf("no compatible QUIC version found (we support %s, server offered %s)", e.Ours, e.Theirs)
}
func (e *VersionNegotiationError) Is(target error) bool {
return target == net.ErrClosed
}
// A StatelessResetError occurs when we receive a stateless reset.
type StatelessResetError struct {
Token protocol.StatelessResetToken
@@ -102,5 +116,9 @@ func (e *StatelessResetError) Error() string {
return fmt.Sprintf("received a stateless reset with token %x", e.Token)
}
func (e *StatelessResetError) Is(target error) bool {
return target == net.ErrClosed
}
func (e *StatelessResetError) Timeout() bool { return false }
func (e *StatelessResetError) Temporary() bool { return true }

View File

@@ -1,14 +0,0 @@
// +build go1.16
package qerr
import (
"net"
)
func (e *TransportError) Is(target error) bool { return target == net.ErrClosed }
func (e *ApplicationError) Is(target error) bool { return target == net.ErrClosed }
func (e *IdleTimeoutError) Is(target error) bool { return target == net.ErrClosed }
func (e *HandshakeTimeoutError) Is(target error) bool { return target == net.ErrClosed }
func (e *VersionNegotiationError) Is(target error) bool { return target == net.ErrClosed }
func (e *StatelessResetError) Is(target error) bool { return target == net.ErrClosed }

View File

@@ -1,22 +0,0 @@
// +build go1.16
package qerr
import (
"errors"
"net"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("QUIC Errors", func() {
It("says that errors are net.ErrClosed errors", func() {
Expect(errors.Is(&TransportError{}, net.ErrClosed)).To(BeTrue())
Expect(errors.Is(&ApplicationError{}, net.ErrClosed)).To(BeTrue())
Expect(errors.Is(&IdleTimeoutError{}, net.ErrClosed)).To(BeTrue())
Expect(errors.Is(&HandshakeTimeoutError{}, net.ErrClosed)).To(BeTrue())
Expect(errors.Is(&StatelessResetError{}, net.ErrClosed)).To(BeTrue())
Expect(errors.Is(&VersionNegotiationError{}, net.ErrClosed)).To(BeTrue())
})
})

View File

@@ -1,6 +1,7 @@
package qerr
import (
"errors"
"net"
"github.com/lucas-clemente/quic-go/internal/protocol"
@@ -114,4 +115,13 @@ var _ = Describe("QUIC Errors", func() {
Expect(nerr.Temporary()).To(BeTrue())
})
})
It("says that errors are net.ErrClosed errors", func() {
Expect(errors.Is(&TransportError{}, net.ErrClosed)).To(BeTrue())
Expect(errors.Is(&ApplicationError{}, net.ErrClosed)).To(BeTrue())
Expect(errors.Is(&IdleTimeoutError{}, net.ErrClosed)).To(BeTrue())
Expect(errors.Is(&HandshakeTimeoutError{}, net.ErrClosed)).To(BeTrue())
Expect(errors.Is(&StatelessResetError{}, net.ErrClosed)).To(BeTrue())
Expect(errors.Is(&VersionNegotiationError{}, net.ErrClosed)).To(BeTrue())
})
})