<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>read on Golang</title><link>https://golang.k5kc.com/tags/read/</link><description>Recent content in read 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/read/index.xml" rel="self" type="application/rss+xml"/><item><title>Buffered read</title><link>https://golang.k5kc.com/2020/08/16/buffered-read/</link><pubDate>Sun, 16 Aug 2020 00:10:00 +0530</pubDate><guid>https://golang.k5kc.com/2020/08/16/buffered-read/</guid><description>bufio package provides buffered read functions. Let&amp;rsquo;s see an example:
(1) Create a test.txt file first:
cat test.txt Output:
abcd efg hijk lmn You can see test.txt contains 4 lines.
(2) See the following program:
package main import ( &amp;#34;bufio&amp;#34; &amp;#34;fmt&amp;#34; &amp;#34;io&amp;#34; &amp;#34;log&amp;#34; &amp;#34;os&amp;#34; ) func main() { f, err := os.Open(&amp;#34;test.txt&amp;#34;) if err != nil { log.Fatal(err) } r := bufio.NewReader(f) for { if s, err := r.ReadSlice(&amp;#39;\n&amp;#39;); err == nil || err == io.</description></item></channel></rss>