<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>reader on Golang</title><link>https://golang.k5kc.com/tags/reader/</link><description>Recent content in reader on Golang</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Sun, 16 Aug 2020 00:10:00 +0530</lastBuildDate><atom:link href="https://golang.k5kc.com/tags/reader/index.xml" rel="self" type="application/rss+xml"/><item><title>Decorate types to implement io.Reader interface</title><link>https://golang.k5kc.com/2020/08/16/decorate-types-to-implement-io-reader-interface/</link><pubDate>Sun, 16 Aug 2020 00:10:00 +0530</pubDate><guid>https://golang.k5kc.com/2020/08/16/decorate-types-to-implement-io-reader-interface/</guid><description>The io package has provided a bunch of handy read functions and methods, but unfortunately, they all require the arguments satisfy io.Reader interface. See the following example:
package main import ( &amp;#34;fmt&amp;#34; &amp;#34;io&amp;#34; ) func main() { s := &amp;#34;Hello, world!&amp;#34; p := make([]byte, len(s)) if _, err := io.ReadFull(s, p); err != nil { fmt.Println(err) } else { fmt.Printf(&amp;#34;%s\n&amp;#34;, p) } } Compile above program and an error is generated:</description></item><item><title>io.Reader interface</title><link>https://golang.k5kc.com/2020/08/16/io-reader-interfaces/</link><pubDate>Sun, 16 Aug 2020 00:10:00 +0530</pubDate><guid>https://golang.k5kc.com/2020/08/16/io-reader-interfaces/</guid><description>io.Reader interface is a basic and very frequently-used interface:
type Reader interface { Read(p []byte) (n int, err error) } For every type who satisfies the io.Reader interface, you can imagine it&amp;rsquo;s a pipe. Someone writes contents into one end of the pipe, and you can use Read() method which the type has provided to read content from the other end of the pipe. No matter it is a common file, a network socket, and so on.</description></item></channel></rss>