Skip to content

Commit 1bb247a

Browse files
doc/go1.15: mention consequence of os.File.ReadFrom
Now that we've added a os.File.ReadFrom method, io.CopyBuffer to a os.File will no longer use the provided buffer. For #16474 For #36817 For #37419 Change-Id: I79a3bf778ff93eab88e88dd9ecbb8c7ea101e868 Reviewed-on: https://go-review.googlesource.com/c/go/+/238864 Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent d7e3a16 commit 1bb247a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

doc/go1.15.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,20 @@ <h3 id="minor_library_changes">Minor changes to the library</h3>
782782
1.14 with the addition of asynchronous preemption. Now this is
783783
handled transparently.
784784
</p>
785+
786+
<p><!-- CL 229101 -->
787+
The <a href="/pkg/os/#File"><code>os.File</code></a> type now
788+
supports a <a href="/pkg/os/#File.ReadFrom"><code>ReadFrom</code></a>
789+
method. This permits the use of the <code>copy_file_range</code>
790+
system call on some systems when using
791+
<a href="/pkg/io/#Copy"><code>io.Copy</code></a> to copy data
792+
from one <code>os.File</code> to another. A consequence is that
793+
<a href="/pkg/io/#CopyBuffer"><code>io.CopyBuffer</code></a>
794+
will not always use the provided buffer when copying to a
795+
<code>os.File</code>. If a program wants to force the use of
796+
the provided buffer, it can be done by writing
797+
<code>io.CopyBuffer(struct{ io.Writer }{dst}, src, buf)</code>.
798+
</p>
785799
</dd>
786800
</dl>
787801

0 commit comments

Comments
 (0)