pkg net/http, type Transport struct, ReadBufferSize int
pkg net/http, type Transport struct, WriteBufferSize int
pkg net, method (*DNSConfigError) Unwrap() error
-pkg net, method (*DNSError) Is(error) bool
-pkg net, method (*OpError) Is(error) bool
pkg net, method (*OpError) Unwrap() error
pkg net, type DNSError struct, IsNotFound bool
pkg net, type ListenConfig struct, KeepAlive time.Duration
pkg os (netbsd-arm64), const O_TRUNC = 1024
pkg os (netbsd-arm64), const PathListSeparator = 58
pkg os (netbsd-arm64), const PathSeparator = 47
-pkg os, var ErrTimeout error
pkg path/filepath (netbsd-arm64-cgo), const ListSeparator = 58
pkg path/filepath (netbsd-arm64-cgo), const Separator = 47
pkg path/filepath (netbsd-arm64), const ListSeparator = 58
import (
"errors"
- "internal/oserror"
"internal/reflectlite"
"sync"
"time"
func (deadlineExceededError) Error() string { return "context deadline exceeded" }
func (deadlineExceededError) Timeout() bool { return true }
func (deadlineExceededError) Temporary() bool { return true }
-func (deadlineExceededError) Is(target error) bool {
- return target == oserror.ErrTimeout
-}
// An emptyCtx is never canceled, has no values, and has no deadline. It is not
// struct{}, since vars of this type must have distinct addresses.
package context
import (
- "errors"
"fmt"
"math/rand"
- "os"
"runtime"
"strings"
"sync"
if !i.Timeout() {
t.Fatal("wrong value for timeout")
}
- if !errors.Is(DeadlineExceeded, os.ErrTimeout) {
- t.Fatal("errors.Is(DeadlineExceeded, os.ErrTimeout) = false, want true")
- }
}
"compress/gzip": {"L4", "compress/flate"},
"compress/lzw": {"L4"},
"compress/zlib": {"L4", "compress/flate"},
- "context": {"errors", "internal/oserror", "internal/reflectlite", "sync", "time"},
+ "context": {"errors", "internal/reflectlite", "sync", "time"},
"database/sql": {"L4", "container/list", "context", "database/sql/driver", "database/sql/internal"},
"database/sql/driver": {"L4", "context", "time", "database/sql/internal"},
"debug/dwarf": {"L4"},
ErrExist = errors.New("file already exists")
ErrNotExist = errors.New("file does not exist")
ErrClosed = errors.New("file already closed")
- ErrTimeout = timeoutError{}
)
-
-type timeoutError struct{}
-
-func (timeoutError) Error() string { return "deadline exceeded" }
-func (timeoutError) Timeout() bool { return true }
-
-type temporaryError struct{}
-
-func (temporaryError) Error() string { return "temporary error" }
-func (temporaryError) Temporary() bool { return true }
-
-// IsTimeout reports whether err indicates a timeout.
-func IsTimeout(err error) bool {
- for err != nil {
- if err == ErrTimeout {
- return true
- }
- if x, ok := err.(interface{ Timeout() bool }); ok {
- return x.Timeout()
- }
- if x, ok := err.(interface{ Is(error) bool }); ok && x.Is(ErrTimeout) {
- return true
- }
- err = errors.Unwrap(err)
- }
- return false
-}
+++ /dev/null
-package oserror_test
-
-import (
- "errors"
- "fmt"
- "internal/oserror"
- "os"
- "testing"
-)
-
-type ttError struct {
- timeout bool
-}
-
-func (e ttError) Error() string {
- return fmt.Sprintf("ttError{timeout:%v}", e.timeout)
-}
-func (e ttError) Timeout() bool { return e.timeout }
-
-type isError struct {
- err error
-}
-
-func (e isError) Error() string { return fmt.Sprintf("isError(%v)", e.err) }
-func (e isError) Is(target error) bool { return e.err == target }
-
-func TestIsTimeout(t *testing.T) {
- for _, test := range []struct {
- want bool
- err error
- }{
- {true, ttError{timeout: true}},
- {true, isError{os.ErrTimeout}},
- {true, os.ErrTimeout},
- {true, fmt.Errorf("wrap: %w", os.ErrTimeout)},
- {false, ttError{timeout: false}},
- {false, errors.New("error")},
- } {
- if got, want := oserror.IsTimeout(test.err), test.want; got != want {
- t.Errorf("IsTimeout(err) = %v, want %v\n%+v", got, want, test.err)
- }
- }
-}
import (
"errors"
- "internal/oserror"
)
// ErrNetClosing is returned when a network descriptor is used after
func (e *TimeoutError) Timeout() bool { return true }
func (e *TimeoutError) Temporary() bool { return true }
-func (e *TimeoutError) Is(target error) bool {
- return target == oserror.ErrTimeout
-}
-
// ErrNotPollable is returned when the file or socket is not suitable
// for event notification.
var ErrNotPollable = errors.New("not pollable")
import (
"context"
- "os"
"syscall"
"unsafe"
)
func (eai addrinfoErrno) Temporary() bool { return eai == C.EAI_AGAIN }
func (eai addrinfoErrno) Timeout() bool { return false }
-func (eai addrinfoErrno) Is(target error) bool {
- switch target {
- case os.ErrTimeout:
- return eai.Timeout()
- }
- return false
-}
-
type portLookupResult struct {
port int
err error
func (e *httpError) Timeout() bool { return e.timeout }
func (e *httpError) Temporary() bool { return true }
-func (e *httpError) Is(target error) bool {
- switch target {
- case os.ErrTimeout:
- return e.timeout
- }
- return false
-}
-
var errTimeout error = &httpError{err: "net/http: timeout awaiting response headers", timeout: true}
// errRequestCanceled is set to be identical to the one from h2 to facilitate
func (tlsHandshakeTimeoutError) Temporary() bool { return true }
func (tlsHandshakeTimeoutError) Error() string { return "net/http: TLS handshake timeout" }
-func (tlsHandshakeTimeoutError) Is(target error) bool {
- return target == os.ErrTimeout
-}
-
// fakeLocker is a sync.Locker which does nothing. It's used to guard
// test-only fields when not under test, to avoid runtime atomic
// overhead.
return ok && t.Temporary()
}
-func (e *OpError) Is(target error) bool {
- switch target {
- case os.ErrTimeout:
- return e.Timeout()
- }
- return false
-}
-
// A ParseError is the error type of literal network address parsers.
type ParseError struct {
// Type is the type of string that was expected, such as
// error and return a DNSError for which Temporary returns false.
func (e *DNSError) Temporary() bool { return e.IsTimeout || e.IsTemporary }
-func (e *DNSError) Is(target error) bool {
- switch target {
- case os.ErrTimeout:
- return e.Timeout()
- }
- return false
-}
-
type writerOnly struct {
io.Writer
}
import (
"io"
- "os"
"sync"
"time"
)
func (timeoutError) Timeout() bool { return true }
func (timeoutError) Temporary() bool { return true }
-func (timeoutError) Is(target error) bool {
- return target == os.ErrTimeout
-}
-
type pipeAddr struct{}
func (pipeAddr) Network() string { return "pipe" }
package net
import (
- "errors"
"fmt"
- "internal/oserror"
"internal/poll"
"internal/testenv"
"io"
if nerr, ok := err.(Error); !ok || !nerr.Timeout() {
t.Fatalf("#%d: %v", i, err)
}
- if !errors.Is(err, oserror.ErrTimeout) {
- t.Fatalf("#%d: Dial error is not os.ErrTimeout: %v", i, err)
- }
}
}
}
import (
"errors"
"fmt"
- "internal/oserror"
"sort"
"strconv"
"strings"
func (e *Error) Unwrap() error { return e.Err }
func (e *Error) Error() string { return e.Op + " " + e.URL + ": " + e.Err.Error() }
-func (e *Error) Timeout() bool { return oserror.IsTimeout(e.Err) }
+
+func (e *Error) Timeout() bool {
+ t, ok := e.Err.(interface {
+ Timeout() bool
+ })
+ return ok && t.Timeout()
+}
func (e *Error) Temporary() bool {
t, ok := e.Err.(interface {
ErrExist = errExist() // "file already exists"
ErrNotExist = errNotExist() // "file does not exist"
ErrClosed = errClosed() // "file already closed"
- ErrTimeout = errTimeout() // "deadline exceeded"
ErrNoDeadline = errNoDeadline() // "file type does not support deadline"
)
func errExist() error { return oserror.ErrExist }
func errNotExist() error { return oserror.ErrNotExist }
func errClosed() error { return oserror.ErrClosed }
-func errTimeout() error { return oserror.ErrTimeout }
func errNoDeadline() error { return poll.ErrNoDeadline }
type timeout interface {
func (e Errno) Is(target error) bool {
switch target {
- case oserror.ErrTimeout:
- return e.Timeout()
case oserror.ErrPermission:
return e == EACCES || e == EPERM
case oserror.ErrExist:
func (e Errno) Is(target error) bool {
switch target {
- case oserror.ErrTimeout:
- return e.Timeout()
case oserror.ErrPermission:
return e == EACCES || e == EPERM
case oserror.ErrExist:
func (e ErrorString) Is(target error) bool {
switch target {
- case oserror.ErrTimeout:
- return e.Timeout()
case oserror.ErrPermission:
return checkErrMessageContent(e, "permission denied")
case oserror.ErrExist:
func (e Errno) Is(target error) bool {
switch target {
- case oserror.ErrTimeout:
- return e.Timeout()
case oserror.ErrPermission:
return e == EACCES || e == EPERM
case oserror.ErrExist:
func (e Errno) Is(target error) bool {
switch target {
- case oserror.ErrTimeout:
- return e.Timeout()
case oserror.ErrPermission:
return e == ERROR_ACCESS_DENIED
case oserror.ErrExist: