Skip to content

Commit 13a16af

Browse files
rvolosatovsdeadprogram
authored andcommitted
net: sync net.go with Go 1.18 stdlib
Signed-off-by: Roman Volosatovs <[email protected]>
1 parent a107b4d commit 13a16af

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/net/net.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// The following is copied from Go 1.16 official implementation.
1+
// The following is copied from Go 1.18 official implementation.
22

33
// Copyright 2009 The Go Authors. All rights reserved.
44
// Use of this source code is governed by a BSD-style
@@ -39,10 +39,10 @@ type Conn interface {
3939
// Any blocked Read or Write operations will be unblocked and return errors.
4040
Close() error
4141

42-
// LocalAddr returns the local network address.
42+
// LocalAddr returns the local network address, if known.
4343
LocalAddr() Addr
4444

45-
// RemoteAddr returns the remote network address.
45+
// RemoteAddr returns the remote network address, if known.
4646
RemoteAddr() Addr
4747

4848
// SetDeadline sets the read and write deadlines associated
@@ -103,8 +103,12 @@ type Listener interface {
103103
// An Error represents a network error.
104104
type Error interface {
105105
error
106-
Timeout() bool // Is the error a timeout?
107-
Temporary() bool // Is the error temporary?
106+
Timeout() bool // Is the error a timeout?
107+
108+
// Deprecated: Temporary errors are not well-defined.
109+
// Most "temporary" errors are timeouts, and the few exceptions are surprising.
110+
// Do not use this method.
111+
Temporary() bool
108112
}
109113

110114
// OpError is the error type usually returned by functions in the net
@@ -220,6 +224,12 @@ var (
220224
_ io.Reader = (*Buffers)(nil)
221225
)
222226

227+
// WriteTo writes contents of the buffers to w.
228+
//
229+
// WriteTo implements io.WriterTo for Buffers.
230+
//
231+
// WriteTo modifies the slice v as well as v[i] for 0 <= i < len(v),
232+
// but does not modify v[i][j] for any i, j.
223233
func (v *Buffers) WriteTo(w io.Writer) (n int64, err error) {
224234
if wv, ok := w.(buffersWriter); ok {
225235
return wv.writeBuffers(v)
@@ -236,6 +246,12 @@ func (v *Buffers) WriteTo(w io.Writer) (n int64, err error) {
236246
return n, nil
237247
}
238248

249+
// Read from the buffers.
250+
//
251+
// Read implements io.Reader for Buffers.
252+
//
253+
// Read modifies the slice v as well as v[i] for 0 <= i < len(v),
254+
// but does not modify v[i][j] for any i, j.
239255
func (v *Buffers) Read(p []byte) (n int, err error) {
240256
for len(p) > 0 && len(*v) > 0 {
241257
n0 := copy(p, (*v)[0])

0 commit comments

Comments
 (0)