net: sync net.go with Go 1.18 stdlib
Signed-off-by: Roman Volosatovs <roman@profian.com>
Этот коммит содержится в:
родитель
a107b4d459
коммит
13a16afc2a
1 изменённых файлов: 21 добавлений и 5 удалений
|
@ -1,4 +1,4 @@
|
||||||
// The following is copied from Go 1.16 official implementation.
|
// The following is copied from Go 1.18 official implementation.
|
||||||
|
|
||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
|
@ -39,10 +39,10 @@ type Conn interface {
|
||||||
// Any blocked Read or Write operations will be unblocked and return errors.
|
// Any blocked Read or Write operations will be unblocked and return errors.
|
||||||
Close() error
|
Close() error
|
||||||
|
|
||||||
// LocalAddr returns the local network address.
|
// LocalAddr returns the local network address, if known.
|
||||||
LocalAddr() Addr
|
LocalAddr() Addr
|
||||||
|
|
||||||
// RemoteAddr returns the remote network address.
|
// RemoteAddr returns the remote network address, if known.
|
||||||
RemoteAddr() Addr
|
RemoteAddr() Addr
|
||||||
|
|
||||||
// SetDeadline sets the read and write deadlines associated
|
// SetDeadline sets the read and write deadlines associated
|
||||||
|
@ -104,7 +104,11 @@ type Listener interface {
|
||||||
type Error interface {
|
type Error interface {
|
||||||
error
|
error
|
||||||
Timeout() bool // Is the error a timeout?
|
Timeout() bool // Is the error a timeout?
|
||||||
Temporary() bool // Is the error temporary?
|
|
||||||
|
// Deprecated: Temporary errors are not well-defined.
|
||||||
|
// Most "temporary" errors are timeouts, and the few exceptions are surprising.
|
||||||
|
// Do not use this method.
|
||||||
|
Temporary() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpError is the error type usually returned by functions in the net
|
// OpError is the error type usually returned by functions in the net
|
||||||
|
@ -220,6 +224,12 @@ var (
|
||||||
_ io.Reader = (*Buffers)(nil)
|
_ io.Reader = (*Buffers)(nil)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// WriteTo writes contents of the buffers to w.
|
||||||
|
//
|
||||||
|
// WriteTo implements io.WriterTo for Buffers.
|
||||||
|
//
|
||||||
|
// WriteTo modifies the slice v as well as v[i] for 0 <= i < len(v),
|
||||||
|
// but does not modify v[i][j] for any i, j.
|
||||||
func (v *Buffers) WriteTo(w io.Writer) (n int64, err error) {
|
func (v *Buffers) WriteTo(w io.Writer) (n int64, err error) {
|
||||||
if wv, ok := w.(buffersWriter); ok {
|
if wv, ok := w.(buffersWriter); ok {
|
||||||
return wv.writeBuffers(v)
|
return wv.writeBuffers(v)
|
||||||
|
@ -236,6 +246,12 @@ func (v *Buffers) WriteTo(w io.Writer) (n int64, err error) {
|
||||||
return n, nil
|
return n, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read from the buffers.
|
||||||
|
//
|
||||||
|
// Read implements io.Reader for Buffers.
|
||||||
|
//
|
||||||
|
// Read modifies the slice v as well as v[i] for 0 <= i < len(v),
|
||||||
|
// but does not modify v[i][j] for any i, j.
|
||||||
func (v *Buffers) Read(p []byte) (n int, err error) {
|
func (v *Buffers) Read(p []byte) (n int, err error) {
|
||||||
for len(p) > 0 && len(*v) > 0 {
|
for len(p) > 0 && len(*v) > 0 {
|
||||||
n0 := copy(p, (*v)[0])
|
n0 := copy(p, (*v)[0])
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче