Go Package io: Difference between revisions
Jump to navigation
Jump to search
(→Writer) |
(→Reader) |
||
Line 18: | Line 18: | ||
<code>Reader</code>s can be used to unmarshall JSON into structs as shown here: {{Internal|JSON_in_Go#With_a_Reader|Unmarshalling JSON from a Reader into a struct}} | <code>Reader</code>s can be used to unmarshall JSON into structs as shown here: {{Internal|JSON_in_Go#With_a_Reader|Unmarshalling JSON from a Reader into a struct}} | ||
Files opened with <code>[[Go_Package_os#os.Create.28.29|os.Create()]]<code> implement <code>io.Reader</code>. | |||
=<tt>Writer</tt>= | =<tt>Writer</tt>= |
Revision as of 00:07, 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
Closer
ReadCloser
An interface that exposes basic Read()
and Close()
methods. The http.Request
body is a ReadCloser
. See Reader
.