Go Package io: Difference between revisions
Jump to navigation
Jump to search
(→Writer) |
(→Closer) |
||
Line 28: | Line 28: | ||
=<tt>Closer</tt>= | =<tt>Closer</tt>= | ||
{{External|https://golang.org/pkg/io/#Closer}} | {{External|https://golang.org/pkg/io/#Closer}} | ||
Files opened with <code>[[Go_Package_os#os.Create.28.29|os.Create()]]</code> implement <code>io.Closer</code>. | |||
=<tt>ReadCloser</tt>= | =<tt>ReadCloser</tt>= | ||
An interface that exposes basic <code>Read()</code> and <code>Close()</code> methods. The <code>http.Request</code> body is a <code>ReadCloser</code>. See <code>[[#Reader|Reader]]</code>. | An interface that exposes basic <code>Read()</code> and <code>Close()</code> methods. The <code>http.Request</code> body is a <code>ReadCloser</code>. See <code>[[#Reader|Reader]]</code>. |
Revision as of 00:10, 19 December 2023
External
Internal
Overview
The io package consists of a few functions, but mostly interfaces used by other packages.
Reader
An interface that exposes Read()
.
Reader
s can be used to unmarshall JSON into structs as shown here:
Files opened with os.Create()
implement io.Reader
.
Writer
Files opened with os.Create()
implement io.Writer
.
Closer
Files opened with os.Create()
implement io.Closer
.
ReadCloser
An interface that exposes basic Read()
and Close()
methods. The http.Request
body is a ReadCloser
. See Reader
.