Skip to content

Commit 69d7ed5

Browse files
dkegel-fastlydeadprogram
authored andcommitted
os: define ErrDeadlineExceeded; fixes go 1.18 compile error in net/http, #2782
1 parent 1116616 commit 69d7ed5

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/os/errors.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@ var (
1818
ErrExist = errors.New("file exists")
1919
)
2020

21+
// The following code is copied from the official implementation.
22+
// src/internal/poll/fd.go
23+
24+
// ErrDeadlineExceeded is returned for an expired deadline.
25+
// This is exported by the os package as os.ErrDeadlineExceeded.
26+
var ErrDeadlineExceeded error = &DeadlineExceededError{}
27+
28+
// DeadlineExceededError is returned for an expired deadline.
29+
type DeadlineExceededError struct{}
30+
31+
// Implement the net.Error interface.
32+
// The string is "i/o timeout" because that is what was returned
33+
// by earlier Go versions. Changing it may break programs that
34+
// match on error strings.
35+
func (e *DeadlineExceededError) Error() string { return "i/o timeout" }
36+
func (e *DeadlineExceededError) Timeout() bool { return true }
37+
func (e *DeadlineExceededError) Temporary() bool { return true }
38+
2139
// The following code is copied from the official implementation.
2240
// https://github.com/golang/go/blob/4ce6a8e89668b87dce67e2f55802903d6eb9110a/src/os/error.go#L65-L104
2341

0 commit comments

Comments
 (0)