You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1276 lines
45 KiB

8 years ago
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <meta name="theme-color" content="#375EAB">
  7. <title>bufio - The Go Programming Language</title>
  8. <link type="text/css" rel="stylesheet" href="../../lib/godoc/style.css">
  9. <link rel="stylesheet" href="../../lib/godoc/jquery.treeview.css">
  10. <script type="text/javascript">window.initFuncs = [];</script>
  11. </head>
  12. <body>
  13. <div id='lowframe' style="position: fixed; bottom: 0; left: 0; height: 0; width: 100%; border-top: thin solid grey; background-color: white; overflow: auto;">
  14. ...
  15. </div><!-- #lowframe -->
  16. <div id="topbar" class="wide"><div class="container">
  17. <div class="top-heading" id="heading-wide"><a href="http://localhost:6060/">The Go Programming Language</a></div>
  18. <div class="top-heading" id="heading-narrow"><a href="http://localhost:6060/">Go</a></div>
  19. <a href="index.html#" id="menu-button"><span id="menu-button-arrow">&#9661;</span></a>
  20. <form method="GET" action="http://localhost:6060/search">
  21. <div id="menu">
  22. <a href="http://localhost:6060/doc/">Documents</a>
  23. <a href="http://localhost:6060/pkg/">Packages</a>
  24. <a href="http://localhost:6060/project/">The Project</a>
  25. <a href="http://localhost:6060/help/">Help</a>
  26. <a href="http://localhost:6060/blog/">Blog</a>
  27. <input type="text" id="search" name="q" class="inactive" value="Search" placeholder="Search">
  28. </div>
  29. </form>
  30. </div></div>
  31. <div id="page" class="wide">
  32. <div class="container">
  33. <h1>Package bufio</h1>
  34. <div id="nav"></div>
  35. <!--
  36. Copyright 2009 The Go Authors. All rights reserved.
  37. Use of this source code is governed by a BSD-style
  38. license that can be found in the LICENSE file.
  39. -->
  40. <!--
  41. Note: Static (i.e., not template-generated) href and id
  42. attributes start with "pkg-" to make it impossible for
  43. them to conflict with generated attributes (some of which
  44. correspond to Go identifiers).
  45. -->
  46. <script type='text/javascript'>
  47. document.ANALYSIS_DATA = null;
  48. document.CALLGRAPH = null;
  49. </script>
  50. <div id="short-nav">
  51. <dl>
  52. <dd><code>import "bufio"</code></dd>
  53. </dl>
  54. <dl>
  55. <dd><a href="index.html#pkg-overview" class="overviewLink">Overview</a></dd>
  56. <dd><a href="index.html#pkg-index" class="indexLink">Index</a></dd>
  57. <dd><a href="index.html#pkg-examples" class="examplesLink">Examples</a></dd>
  58. </dl>
  59. </div>
  60. <!-- The package's Name is printed as title by the top-level template -->
  61. <div id="pkg-overview" class="toggleVisible">
  62. <div class="collapsed">
  63. <h2 class="toggleButton" title="Click to show Overview section">Overview ▹</h2>
  64. </div>
  65. <div class="expanded">
  66. <h2 class="toggleButton" title="Click to hide Overview section">Overview ▾</h2>
  67. <p>
  68. Package bufio implements buffered I/O. It wraps an io.Reader or io.Writer
  69. object, creating another object (Reader or Writer) that also implements
  70. the interface but provides buffering and some help for textual I/O.
  71. </p>
  72. </div>
  73. </div>
  74. <div id="pkg-index" class="toggleVisible">
  75. <div class="collapsed">
  76. <h2 class="toggleButton" title="Click to show Index section">Index ▹</h2>
  77. </div>
  78. <div class="expanded">
  79. <h2 class="toggleButton" title="Click to hide Index section">Index ▾</h2>
  80. <!-- Table of contents for API; must be named manual-nav to turn off auto nav. -->
  81. <div id="manual-nav">
  82. <dl>
  83. <dd><a href="index.html#pkg-constants">Constants</a></dd>
  84. <dd><a href="index.html#pkg-variables">Variables</a></dd>
  85. <dd><a href="index.html#ScanBytes">func ScanBytes(data []byte, atEOF bool) (advance int, token []byte, err error)</a></dd>
  86. <dd><a href="index.html#ScanLines">func ScanLines(data []byte, atEOF bool) (advance int, token []byte, err error)</a></dd>
  87. <dd><a href="index.html#ScanRunes">func ScanRunes(data []byte, atEOF bool) (advance int, token []byte, err error)</a></dd>
  88. <dd><a href="index.html#ScanWords">func ScanWords(data []byte, atEOF bool) (advance int, token []byte, err error)</a></dd>
  89. <dd><a href="index.html#ReadWriter">type ReadWriter</a></dd>
  90. <dd>&nbsp; &nbsp; <a href="index.html#NewReadWriter">func NewReadWriter(r *Reader, w *Writer) *ReadWriter</a></dd>
  91. <dd><a href="index.html#Reader">type Reader</a></dd>
  92. <dd>&nbsp; &nbsp; <a href="index.html#NewReader">func NewReader(rd io.Reader) *Reader</a></dd>
  93. <dd>&nbsp; &nbsp; <a href="index.html#NewReaderSize">func NewReaderSize(rd io.Reader, size int) *Reader</a></dd>
  94. <dd>&nbsp; &nbsp; <a href="index.html#Reader.Buffered">func (b *Reader) Buffered() int</a></dd>
  95. <dd>&nbsp; &nbsp; <a href="index.html#Reader.Discard">func (b *Reader) Discard(n int) (discarded int, err error)</a></dd>
  96. <dd>&nbsp; &nbsp; <a href="index.html#Reader.Peek">func (b *Reader) Peek(n int) ([]byte, error)</a></dd>
  97. <dd>&nbsp; &nbsp; <a href="index.html#Reader.Read">func (b *Reader) Read(p []byte) (n int, err error)</a></dd>
  98. <dd>&nbsp; &nbsp; <a href="index.html#Reader.ReadByte">func (b *Reader) ReadByte() (c byte, err error)</a></dd>
  99. <dd>&nbsp; &nbsp; <a href="index.html#Reader.ReadBytes">func (b *Reader) ReadBytes(delim byte) (line []byte, err error)</a></dd>
  100. <dd>&nbsp; &nbsp; <a href="index.html#Reader.ReadLine">func (b *Reader) ReadLine() (line []byte, isPrefix bool, err error)</a></dd>
  101. <dd>&nbsp; &nbsp; <a href="index.html#Reader.ReadRune">func (b *Reader) ReadRune() (r rune, size int, err error)</a></dd>
  102. <dd>&nbsp; &nbsp; <a href="index.html#Reader.ReadSlice">func (b *Reader) ReadSlice(delim byte) (line []byte, err error)</a></dd>
  103. <dd>&nbsp; &nbsp; <a href="index.html#Reader.ReadString">func (b *Reader) ReadString(delim byte) (line string, err error)</a></dd>
  104. <dd>&nbsp; &nbsp; <a href="index.html#Reader.Reset">func (b *Reader) Reset(r io.Reader)</a></dd>
  105. <dd>&nbsp; &nbsp; <a href="index.html#Reader.UnreadByte">func (b *Reader) UnreadByte() error</a></dd>
  106. <dd>&nbsp; &nbsp; <a href="index.html#Reader.UnreadRune">func (b *Reader) UnreadRune() error</a></dd>
  107. <dd>&nbsp; &nbsp; <a href="index.html#Reader.WriteTo">func (b *Reader) WriteTo(w io.Writer) (n int64, err error)</a></dd>
  108. <dd><a href="index.html#Scanner">type Scanner</a></dd>
  109. <dd>&nbsp; &nbsp; <a href="index.html#NewScanner">func NewScanner(r io.Reader) *Scanner</a></dd>
  110. <dd>&nbsp; &nbsp; <a href="index.html#Scanner.Buffer">func (s *Scanner) Buffer(buf []byte, max int)</a></dd>
  111. <dd>&nbsp; &nbsp; <a href="index.html#Scanner.Bytes">func (s *Scanner) Bytes() []byte</a></dd>
  112. <dd>&nbsp; &nbsp; <a href="index.html#Scanner.Err">func (s *Scanner) Err() error</a></dd>
  113. <dd>&nbsp; &nbsp; <a href="index.html#Scanner.Scan">func (s *Scanner) Scan() bool</a></dd>
  114. <dd>&nbsp; &nbsp; <a href="index.html#Scanner.Split">func (s *Scanner) Split(split SplitFunc)</a></dd>
  115. <dd>&nbsp; &nbsp; <a href="index.html#Scanner.Text">func (s *Scanner) Text() string</a></dd>
  116. <dd><a href="index.html#SplitFunc">type SplitFunc</a></dd>
  117. <dd><a href="index.html#Writer">type Writer</a></dd>
  118. <dd>&nbsp; &nbsp; <a href="index.html#NewWriter">func NewWriter(w io.Writer) *Writer</a></dd>
  119. <dd>&nbsp; &nbsp; <a href="index.html#NewWriterSize">func NewWriterSize(w io.Writer, size int) *Writer</a></dd>
  120. <dd>&nbsp; &nbsp; <a href="index.html#Writer.Available">func (b *Writer) Available() int</a></dd>
  121. <dd>&nbsp; &nbsp; <a href="index.html#Writer.Buffered">func (b *Writer) Buffered() int</a></dd>
  122. <dd>&nbsp; &nbsp; <a href="index.html#Writer.Flush">func (b *Writer) Flush() error</a></dd>
  123. <dd>&nbsp; &nbsp; <a href="index.html#Writer.ReadFrom">func (b *Writer) ReadFrom(r io.Reader) (n int64, err error)</a></dd>
  124. <dd>&nbsp; &nbsp; <a href="index.html#Writer.Reset">func (b *Writer) Reset(w io.Writer)</a></dd>
  125. <dd>&nbsp; &nbsp; <a href="index.html#Writer.Write">func (b *Writer) Write(p []byte) (nn int, err error)</a></dd>
  126. <dd>&nbsp; &nbsp; <a href="index.html#Writer.WriteByte">func (b *Writer) WriteByte(c byte) error</a></dd>
  127. <dd>&nbsp; &nbsp; <a href="index.html#Writer.WriteRune">func (b *Writer) WriteRune(r rune) (size int, err error)</a></dd>
  128. <dd>&nbsp; &nbsp; <a href="index.html#Writer.WriteString">func (b *Writer) WriteString(s string) (int, error)</a></dd>
  129. </dl>
  130. </div><!-- #manual-nav -->
  131. <div id="pkg-examples">
  132. <h4>Examples</h4>
  133. <dl>
  134. <dd><a class="exampleLink" href="index.html#example_Scanner_custom">Scanner (Custom)</a></dd>
  135. <dd><a class="exampleLink" href="index.html#example_Scanner_emptyFinalToken">Scanner (EmptyFinalToken)</a></dd>
  136. <dd><a class="exampleLink" href="index.html#example_Scanner_lines">Scanner (Lines)</a></dd>
  137. <dd><a class="exampleLink" href="index.html#example_Scanner_words">Scanner (Words)</a></dd>
  138. <dd><a class="exampleLink" href="index.html#example_Writer">Writer</a></dd>
  139. </dl>
  140. </div>
  141. <h4>Package files</h4>
  142. <p>
  143. <span style="font-size:90%">
  144. <a href="http://localhost:6060/src/bufio/bufio.go">bufio.go</a>
  145. <a href="http://localhost:6060/src/bufio/scan.go">scan.go</a>
  146. </span>
  147. </p>
  148. </div><!-- .expanded -->
  149. </div><!-- #pkg-index -->
  150. <div id="pkg-callgraph" class="toggle" style="display: none">
  151. <div class="collapsed">
  152. <h2 class="toggleButton" title="Click to show Internal Call Graph section">Internal call graph ▹</h2>
  153. </div> <!-- .expanded -->
  154. <div class="expanded">
  155. <h2 class="toggleButton" title="Click to hide Internal Call Graph section">Internal call graph ▾</h2>
  156. <p>
  157. In the call graph viewer below, each node
  158. is a function belonging to this package
  159. and its children are the functions it
  160. calls&mdash;perhaps dynamically.
  161. </p>
  162. <p>
  163. The root nodes are the entry points of the
  164. package: functions that may be called from
  165. outside the package.
  166. There may be non-exported or anonymous
  167. functions among them if they are called
  168. dynamically from another package.
  169. </p>
  170. <p>
  171. Click a node to visit that function's source code.
  172. From there you can visit its callers by
  173. clicking its declaring <code>func</code>
  174. token.
  175. </p>
  176. <p>
  177. Functions may be omitted if they were
  178. determined to be unreachable in the
  179. particular programs or tests that were
  180. analyzed.
  181. </p>
  182. <!-- Zero means show all package entry points. -->
  183. <ul style="margin-left: 0.5in" id="callgraph-0" class="treeview"></ul>
  184. </div>
  185. </div> <!-- #pkg-callgraph -->
  186. <h2 id="pkg-constants">Constants</h2>
  187. <pre>const (
  188. <span class="comment">// MaxScanTokenSize is the maximum size used to buffer a token</span>
  189. <span class="comment">// unless the user provides an explicit buffer with Scan.Buffer.</span>
  190. <span class="comment">// The actual maximum token size may be smaller as the buffer</span>
  191. <span class="comment">// may need to include, for instance, a newline.</span>
  192. <span id="MaxScanTokenSize">MaxScanTokenSize</span> = 64 * 1024
  193. )</pre>
  194. <h2 id="pkg-variables">Variables</h2>
  195. <pre>var (
  196. <span id="ErrInvalidUnreadByte">ErrInvalidUnreadByte</span> = <a href="../errors/index.html">errors</a>.<a href="../errors/index.html#New">New</a>(&#34;bufio: invalid use of UnreadByte&#34;)
  197. <span id="ErrInvalidUnreadRune">ErrInvalidUnreadRune</span> = <a href="../errors/index.html">errors</a>.<a href="../errors/index.html#New">New</a>(&#34;bufio: invalid use of UnreadRune&#34;)
  198. <span id="ErrBufferFull">ErrBufferFull</span> = <a href="../errors/index.html">errors</a>.<a href="../errors/index.html#New">New</a>(&#34;bufio: buffer full&#34;)
  199. <span id="ErrNegativeCount">ErrNegativeCount</span> = <a href="../errors/index.html">errors</a>.<a href="../errors/index.html#New">New</a>(&#34;bufio: negative count&#34;)
  200. )</pre>
  201. <pre>var (
  202. <span id="ErrTooLong">ErrTooLong</span> = <a href="../errors/index.html">errors</a>.<a href="../errors/index.html#New">New</a>(&#34;bufio.Scanner: token too long&#34;)
  203. <span id="ErrNegativeAdvance">ErrNegativeAdvance</span> = <a href="../errors/index.html">errors</a>.<a href="../errors/index.html#New">New</a>(&#34;bufio.Scanner: SplitFunc returns negative advance count&#34;)
  204. <span id="ErrAdvanceTooFar">ErrAdvanceTooFar</span> = <a href="../errors/index.html">errors</a>.<a href="../errors/index.html#New">New</a>(&#34;bufio.Scanner: SplitFunc returns advance count beyond input&#34;)
  205. )</pre>
  206. <p>
  207. Errors returned by Scanner.
  208. </p>
  209. <pre>var <span id="ErrFinalToken">ErrFinalToken</span> = <a href="../errors/index.html">errors</a>.<a href="../errors/index.html#New">New</a>(&#34;final token&#34;)</pre>
  210. <p>
  211. ErrFinalToken is a special sentinel error value. It is intended to be
  212. returned by a Split function to indicate that the token being delivered
  213. with the error is the last token and scanning should stop after this one.
  214. After ErrFinalToken is received by Scan, scanning stops with no error.
  215. The value is useful to stop processing early or when it is necessary to
  216. deliver a final empty token. One could achieve the same behavior
  217. with a custom error value but providing one here is tidier.
  218. See the emptyFinalToken example for a use of this value.
  219. </p>
  220. <h2 id="ScanBytes">func <a href="http://localhost:6060/src/bufio/scan.go?s=9294:9372#L269">ScanBytes</a></h2>
  221. <pre>func ScanBytes(data []<a href="../builtin/index.html#byte">byte</a>, atEOF <a href="../builtin/index.html#bool">bool</a>) (advance <a href="../builtin/index.html#int">int</a>, token []<a href="../builtin/index.html#byte">byte</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
  222. <p>
  223. ScanBytes is a split function for a Scanner that returns each byte as a token.
  224. </p>
  225. <h2 id="ScanLines">func <a href="http://localhost:6060/src/bufio/scan.go?s=11500:11578#L330">ScanLines</a></h2>
  226. <pre>func ScanLines(data []<a href="../builtin/index.html#byte">byte</a>, atEOF <a href="../builtin/index.html#bool">bool</a>) (advance <a href="../builtin/index.html#int">int</a>, token []<a href="../builtin/index.html#byte">byte</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
  227. <p>
  228. ScanLines is a split function for a Scanner that returns each line of
  229. text, stripped of any trailing end-of-line marker. The returned line may
  230. be empty. The end-of-line marker is one optional carriage return followed
  231. by one mandatory newline. In regular expression notation, it is `\r?\n`.
  232. The last non-empty line of input will be returned even if it has no
  233. newline.
  234. </p>
  235. <h2 id="ScanRunes">func <a href="http://localhost:6060/src/bufio/scan.go?s=9941:10019#L284">ScanRunes</a></h2>
  236. <pre>func ScanRunes(data []<a href="../builtin/index.html#byte">byte</a>, atEOF <a href="../builtin/index.html#bool">bool</a>) (advance <a href="../builtin/index.html#int">int</a>, token []<a href="../builtin/index.html#byte">byte</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
  237. <p>
  238. ScanRunes is a split function for a Scanner that returns each
  239. UTF-8-encoded rune as a token. The sequence of runes returned is
  240. equivalent to that from a range loop over the input as a string, which
  241. means that erroneous UTF-8 encodings translate to U+FFFD = &#34;\xef\xbf\xbd&#34;.
  242. Because of the Scan interface, this makes it impossible for the client to
  243. distinguish correctly encoded replacement runes from encoding errors.
  244. </p>
  245. <h2 id="ScanWords">func <a href="http://localhost:6060/src/bufio/scan.go?s=12794:12872#L375">ScanWords</a></h2>
  246. <pre>func ScanWords(data []<a href="../builtin/index.html#byte">byte</a>, atEOF <a href="../builtin/index.html#bool">bool</a>) (advance <a href="../builtin/index.html#int">int</a>, token []<a href="../builtin/index.html#byte">byte</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
  247. <p>
  248. ScanWords is a split function for a Scanner that returns each
  249. space-separated word of text, with surrounding spaces deleted. It will
  250. never return an empty string. The definition of space is set by
  251. unicode.IsSpace.
  252. </p>
  253. <h2 id="ReadWriter">type <a href="http://localhost:6060/src/bufio/bufio.go?s=17449:17493#L712">ReadWriter</a></h2>
  254. <pre>type ReadWriter struct {
  255. *<a href="index.html#Reader">Reader</a>
  256. *<a href="index.html#Writer">Writer</a>
  257. }</pre>
  258. <p>
  259. ReadWriter stores pointers to a Reader and a Writer.
  260. It implements io.ReadWriter.
  261. </p>
  262. <h3 id="NewReadWriter">func <a href="http://localhost:6060/src/bufio/bufio.go?s=17567:17619#L718">NewReadWriter</a></h3>
  263. <pre>func NewReadWriter(r *<a href="index.html#Reader">Reader</a>, w *<a href="index.html#Writer">Writer</a>) *<a href="index.html#ReadWriter">ReadWriter</a></pre>
  264. <p>
  265. NewReadWriter allocates a new ReadWriter that dispatches to r and w.
  266. </p>
  267. <h2 id="Reader">type <a href="http://localhost:6060/src/bufio/bufio.go?s=830:1042#L21">Reader</a></h2>
  268. <pre>type Reader struct {
  269. <span class="comment">// contains filtered or unexported fields</span>
  270. }</pre>
  271. <p>
  272. Reader implements buffering for an io.Reader object.
  273. </p>
  274. <h3 id="NewReader">func <a href="http://localhost:6060/src/bufio/bufio.go?s=1648:1684#L51">NewReader</a></h3>
  275. <pre>func NewReader(rd <a href="../io/index.html">io</a>.<a href="../io/index.html#Reader">Reader</a>) *<a href="index.html#Reader">Reader</a></pre>
  276. <p>
  277. NewReader returns a new Reader whose buffer has the default size.
  278. </p>
  279. <h3 id="NewReaderSize">func <a href="http://localhost:6060/src/bufio/bufio.go?s=1305:1355#L36">NewReaderSize</a></h3>
  280. <pre>func NewReaderSize(rd <a href="../io/index.html">io</a>.<a href="../io/index.html#Reader">Reader</a>, size <a href="../builtin/index.html#int">int</a>) *<a href="index.html#Reader">Reader</a></pre>
  281. <p>
  282. NewReaderSize returns a new Reader whose buffer has at least the specified
  283. size. If the argument io.Reader is already a Reader with large enough
  284. size, it returns the underlying Reader.
  285. </p>
  286. <h3 id="Reader.Buffered">func (*Reader) <a href="http://localhost:6060/src/bufio/bufio.go?s=7000:7031#L281">Buffered</a></h3>
  287. <pre>func (b *<a href="index.html#Reader">Reader</a>) Buffered() <a href="../builtin/index.html#int">int</a></pre>
  288. <p>
  289. Buffered returns the number of bytes that can be read from the current buffer.
  290. </p>
  291. <h3 id="Reader.Discard">func (*Reader) <a href="http://localhost:6060/src/bufio/bufio.go?s=3757:3815#L142">Discard</a></h3>
  292. <pre>func (b *<a href="index.html#Reader">Reader</a>) Discard(n <a href="../builtin/index.html#int">int</a>) (discarded <a href="../builtin/index.html#int">int</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
  293. <p>
  294. Discard skips the next n bytes, returning the number of bytes discarded.
  295. </p>
  296. <p>
  297. If Discard skips fewer than n bytes, it also returns an error.
  298. If 0 &lt;= n &lt;= b.Buffered(), Discard is guaranteed to succeed without
  299. reading from the underlying io.Reader.
  300. </p>
  301. <h3 id="Reader.Peek">func (*Reader) <a href="http://localhost:6060/src/bufio/bufio.go?s=3036:3080#L113">Peek</a></h3>
  302. <pre>func (b *<a href="index.html#Reader">Reader</a>) Peek(n <a href="../builtin/index.html#int">int</a>) ([]<a href="../builtin/index.html#byte">byte</a>, <a href="../builtin/index.html#error">error</a>)</pre>
  303. <p>
  304. Peek returns the next n bytes without advancing the reader. The bytes stop
  305. being valid at the next read call. If Peek returns fewer than n bytes, it
  306. also returns an error explaining why the read is short. The error is
  307. ErrBufferFull if n is larger than b&#39;s buffer size.
  308. </p>
  309. <h3 id="Reader.Read">func (*Reader) <a href="http://localhost:6060/src/bufio/bufio.go?s=4402:4452#L175">Read</a></h3>
  310. <pre>func (b *<a href="index.html#Reader">Reader</a>) Read(p []<a href="../builtin/index.html#byte">byte</a>) (n <a href="../builtin/index.html#int">int</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
  311. <p>
  312. Read reads data into p.
  313. It returns the number of bytes read into p.
  314. The bytes are taken from at most one Read on the underlying Reader,
  315. hence n may be less than len(p).
  316. At EOF, the count will be zero and err will be io.EOF.
  317. </p>
  318. <h3 id="Reader.ReadByte">func (*Reader) <a href="http://localhost:6060/src/bufio/bufio.go?s=5158:5205#L213">ReadByte</a></h3>
  319. <pre>func (b *<a href="index.html#Reader">Reader</a>) ReadByte() (c <a href="../builtin/index.html#byte">byte</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
  320. <p>
  321. ReadByte reads and returns a single byte.
  322. If no byte is available, returns an error.
  323. </p>
  324. <h3 id="Reader.ReadBytes">func (*Reader) <a href="http://localhost:6060/src/bufio/bufio.go?s=10455:10518#L388">ReadBytes</a></h3>
  325. <pre>func (b *<a href="index.html#Reader">Reader</a>) ReadBytes(delim <a href="../builtin/index.html#byte">byte</a>) (line []<a href="../builtin/index.html#byte">byte</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
  326. <p>
  327. ReadBytes reads until the first occurrence of delim in the input,
  328. returning a slice containing the data up to and including the delimiter.
  329. If ReadBytes encounters an error before finding a delimiter,
  330. it returns the data read before the error and the error itself (often io.EOF).
  331. ReadBytes returns err != nil if and only if the returned data does not end in
  332. delim.
  333. For simple uses, a Scanner may be more convenient.
  334. </p>
  335. <h3 id="Reader.ReadLine">func (*Reader) <a href="http://localhost:6060/src/bufio/bufio.go?s=9262:9329#L346">ReadLine</a></h3>
  336. <pre>func (b *<a href="index.html#Reader">Reader</a>) ReadLine() (line []<a href="../builtin/index.html#byte">byte</a>, isPrefix <a href="../builtin/index.html#bool">bool</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
  337. <p>
  338. ReadLine is a low-level line-reading primitive. Most callers should use
  339. ReadBytes(&#39;\n&#39;) or ReadString(&#39;\n&#39;) instead or use a Scanner.
  340. </p>
  341. <p>
  342. ReadLine tries to return a single line, not including the end-of-line bytes.
  343. If the line was too long for the buffer then isPrefix is set and the
  344. beginning of the line is returned. The rest of the line will be returned
  345. from future calls. isPrefix will be false when returning the last fragment
  346. of the line. The returned buffer is only valid until the next call to
  347. ReadLine. ReadLine either returns a non-nil line or it returns an error,
  348. never both.
  349. </p>
  350. <p>
  351. The text returned from ReadLine does not include the line end (&#34;\r\n&#34; or &#34;\n&#34;).
  352. No indication or error is given if the input ends without a final line end.
  353. Calling UnreadByte after ReadLine will always unread the last byte read
  354. (possibly a character belonging to the line end) even if that byte is not
  355. part of the line returned by ReadLine.
  356. </p>
  357. <h3 id="Reader.ReadRune">func (*Reader) <a href="http://localhost:6060/src/bufio/bufio.go?s=5996:6053#L248">ReadRune</a></h3>
  358. <pre>func (b *<a href="index.html#Reader">Reader</a>) ReadRune() (r <a href="../builtin/index.html#rune">rune</a>, size <a href="../builtin/index.html#int">int</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
  359. <p>
  360. ReadRune reads a single UTF-8 encoded Unicode character and returns the
  361. rune and its size in bytes. If the encoded rune is invalid, it consumes one byte
  362. and returns unicode.ReplacementChar (U+FFFD) with a size of 1.
  363. </p>
  364. <h3 id="Reader.ReadSlice">func (*Reader) <a href="http://localhost:6060/src/bufio/bufio.go?s=7681:7744#L293">ReadSlice</a></h3>
  365. <pre>func (b *<a href="index.html#Reader">Reader</a>) ReadSlice(delim <a href="../builtin/index.html#byte">byte</a>) (line []<a href="../builtin/index.html#byte">byte</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
  366. <p>
  367. ReadSlice reads until the first occurrence of delim in the input,
  368. returning a slice pointing at the bytes in the buffer.
  369. The bytes stop being valid at the next read.
  370. If ReadSlice encounters an error before finding a delimiter,
  371. it returns all the data in the buffer and the error itself (often io.EOF).
  372. ReadSlice fails with error ErrBufferFull if the buffer fills without a delim.
  373. Because the data returned from ReadSlice will be overwritten
  374. by the next I/O operation, most clients should use
  375. ReadBytes or ReadString instead.
  376. ReadSlice returns err != nil if and only if line does not end in delim.
  377. </p>
  378. <h3 id="Reader.ReadString">func (*Reader) <a href="http://localhost:6060/src/bufio/bufio.go?s=11657:11721#L435">ReadString</a></h3>
  379. <pre>func (b *<a href="index.html#Reader">Reader</a>) ReadString(delim <a href="../builtin/index.html#byte">byte</a>) (line <a href="../builtin/index.html#string">string</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
  380. <p>
  381. ReadString reads until the first occurrence of delim in the input,
  382. returning a string containing the data up to and including the delimiter.
  383. If ReadString encounters an error before finding a delimiter,
  384. it returns the data read before the error and the error itself (often io.EOF).
  385. ReadString returns err != nil if and only if the returned data does not end in
  386. delim.
  387. For simple uses, a Scanner may be more convenient.
  388. </p>
  389. <h3 id="Reader.Reset">func (*Reader) <a href="http://localhost:6060/src/bufio/bufio.go?s=1839:1874#L57">Reset</a></h3>
  390. <pre>func (b *<a href="index.html#Reader">Reader</a>) Reset(r <a href="../io/index.html">io</a>.<a href="../io/index.html#Reader">Reader</a>)</pre>
  391. <p>
  392. Reset discards any buffered data, resets all state, and switches
  393. the buffered reader to read from r.
  394. </p>
  395. <h3 id="Reader.UnreadByte">func (*Reader) <a href="http://localhost:6060/src/bufio/bufio.go?s=5477:5512#L228">UnreadByte</a></h3>
  396. <pre>func (b *<a href="index.html#Reader">Reader</a>) UnreadByte() <a href="../builtin/index.html#error">error</a></pre>
  397. <p>
  398. UnreadByte unreads the last byte. Only the most recently read byte can be unread.
  399. </p>
  400. <h3 id="Reader.UnreadRune">func (*Reader) <a href="http://localhost:6060/src/bufio/bufio.go?s=6722:6757#L270">UnreadRune</a></h3>
  401. <pre>func (b *<a href="index.html#Reader">Reader</a>) UnreadRune() <a href="../builtin/index.html#error">error</a></pre>
  402. <p>
  403. UnreadRune unreads the last rune. If the most recent read operation on
  404. the buffer was not a ReadRune, UnreadRune returns an error. (In this
  405. regard it is stricter than UnreadByte, which will unread the last byte
  406. from any read operation.)
  407. </p>
  408. <h3 id="Reader.WriteTo">func (*Reader) <a href="http://localhost:6060/src/bufio/bufio.go?s=11836:11894#L442">WriteTo</a></h3>
  409. <pre>func (b *<a href="index.html#Reader">Reader</a>) WriteTo(w <a href="../io/index.html">io</a>.<a href="../io/index.html#Writer">Writer</a>) (n <a href="../builtin/index.html#int64">int64</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
  410. <p>
  411. WriteTo implements io.WriterTo.
  412. </p>
  413. <h2 id="Scanner">type <a href="http://localhost:6060/src/bufio/scan.go?s=1184:1841#L20">Scanner</a></h2>
  414. <pre>type Scanner struct {
  415. <span class="comment">// contains filtered or unexported fields</span>
  416. }</pre>
  417. <p>
  418. Scanner provides a convenient interface for reading data such as
  419. a file of newline-delimited lines of text. Successive calls to
  420. the Scan method will step through the &#39;tokens&#39; of a file, skipping
  421. the bytes between the tokens. The specification of a token is
  422. defined by a split function of type SplitFunc; the default split
  423. function breaks the input into lines with line termination stripped. Split
  424. functions are defined in this package for scanning a file into
  425. lines, bytes, UTF-8-encoded runes, and space-delimited words. The
  426. client may instead provide a custom split function.
  427. </p>
  428. <p>
  429. Scanning stops unrecoverably at EOF, the first I/O error, or a token too
  430. large to fit in the buffer. When a scan stops, the reader may have
  431. advanced arbitrarily far past the last token. Programs that need more
  432. control over error handling or large tokens, or must run sequential scans
  433. on a reader, should use bufio.Reader instead.
  434. </p>
  435. <div id="example_Scanner_custom" class="toggle">
  436. <div class="collapsed">
  437. <p class="exampleHeading toggleButton"><span class="text">Example (Custom)</span></p>
  438. </div>
  439. <div class="expanded">
  440. <p class="exampleHeading toggleButton"><span class="text">Example (Custom)</span></p>
  441. <p>Use a Scanner with a custom split function (built by wrapping ScanWords) to validate
  442. 32-bit decimal input.
  443. </p>
  444. <p>Code:</p>
  445. <pre class="code"><span class="comment">// An artificial input source.</span>
  446. const input = &#34;1234 5678 1234567901234567890&#34;
  447. scanner := bufio.NewScanner(strings.NewReader(input))
  448. <span class="comment">// Create a custom split function by wrapping the existing ScanWords function.</span>
  449. split := func(data []byte, atEOF bool) (advance int, token []byte, err error) {
  450. advance, token, err = bufio.ScanWords(data, atEOF)
  451. if err == nil &amp;&amp; token != nil {
  452. _, err = strconv.ParseInt(string(token), 10, 32)
  453. }
  454. return
  455. }
  456. <span class="comment">// Set the split function for the scanning operation.</span>
  457. scanner.Split(split)
  458. <span class="comment">// Validate the input</span>
  459. for scanner.Scan() {
  460. fmt.Printf(&#34;%s\n&#34;, scanner.Text())
  461. }
  462. if err := scanner.Err(); err != nil {
  463. fmt.Printf(&#34;Invalid input: %s&#34;, err)
  464. }
  465. <span class="comment"></pre>
  466. <p>Output:</p>
  467. <pre class="output">1234
  468. 5678
  469. Invalid input: strconv.ParseInt: parsing &#34;1234567901234567890&#34;: value out of range
  470. </pre>
  471. </div>
  472. </div>
  473. <div id="example_Scanner_emptyFinalToken" class="toggle">
  474. <div class="collapsed">
  475. <p class="exampleHeading toggleButton"><span class="text">Example (EmptyFinalToken)</span></p>
  476. </div>
  477. <div class="expanded">
  478. <p class="exampleHeading toggleButton"><span class="text">Example (EmptyFinalToken)</span></p>
  479. <p>Use a Scanner with a custom split function to parse a comma-separated
  480. list with an empty final value.
  481. </p>
  482. <p>Code:</p>
  483. <pre class="code"><span class="comment">// Comma-separated list; last entry is empty.</span>
  484. const input = &#34;1,2,3,4,&#34;
  485. scanner := bufio.NewScanner(strings.NewReader(input))
  486. <span class="comment">// Define a split function that separates on commas.</span>
  487. onComma := func(data []byte, atEOF bool) (advance int, token []byte, err error) {
  488. for i := 0; i &lt; len(data); i++ {
  489. if data[i] == &#39;,&#39; {
  490. return i + 1, data[:i], nil
  491. }
  492. }
  493. <span class="comment">// There is one final token to be delivered, which may be the empty string.</span>
  494. <span class="comment">// Returning bufio.ErrFinalToken here tells Scan there are no more tokens after this</span>
  495. <span class="comment">// but does not trigger an error to be returned from Scan itself.</span>
  496. return 0, data, bufio.ErrFinalToken
  497. }
  498. scanner.Split(onComma)
  499. <span class="comment">// Scan.</span>
  500. for scanner.Scan() {
  501. fmt.Printf(&#34;%q &#34;, scanner.Text())
  502. }
  503. if err := scanner.Err(); err != nil {
  504. fmt.Fprintln(os.Stderr, &#34;reading input:&#34;, err)
  505. }
  506. <span class="comment"></pre>
  507. <p>Output:</p>
  508. <pre class="output">&#34;1&#34; &#34;2&#34; &#34;3&#34; &#34;4&#34; &#34;&#34;
  509. </pre>
  510. </div>
  511. </div>
  512. <div id="example_Scanner_lines" class="toggle">
  513. <div class="collapsed">
  514. <p class="exampleHeading toggleButton"><span class="text">Example (Lines)</span></p>
  515. </div>
  516. <div class="expanded">
  517. <p class="exampleHeading toggleButton"><span class="text">Example (Lines)</span></p>
  518. <p>The simplest use of a Scanner, to read standard input as a set of lines.
  519. </p>
  520. <p>Code:</p>
  521. <pre class="code">
  522. scanner := bufio.NewScanner(os.Stdin)
  523. for scanner.Scan() {
  524. fmt.Println(scanner.Text()) <span class="comment">// Println will add back the final &#39;\n&#39;</span>
  525. }
  526. if err := scanner.Err(); err != nil {
  527. fmt.Fprintln(os.Stderr, &#34;reading standard input:&#34;, err)
  528. }
  529. </pre>
  530. </div>
  531. </div>
  532. <div id="example_Scanner_words" class="toggle">
  533. <div class="collapsed">
  534. <p class="exampleHeading toggleButton"><span class="text">Example (Words)</span></p>
  535. </div>
  536. <div class="expanded">
  537. <p class="exampleHeading toggleButton"><span class="text">Example (Words)</span></p>
  538. <p>Use a Scanner to implement a simple word-count utility by scanning the
  539. input as a sequence of space-delimited tokens.
  540. </p>
  541. <p>Code:</p>
  542. <pre class="code"><span class="comment">// An artificial input source.</span>
  543. const input = &#34;Now is the winter of our discontent,\nMade glorious summer by this sun of York.\n&#34;
  544. scanner := bufio.NewScanner(strings.NewReader(input))
  545. <span class="comment">// Set the split function for the scanning operation.</span>
  546. scanner.Split(bufio.ScanWords)
  547. <span class="comment">// Count the words.</span>
  548. count := 0
  549. for scanner.Scan() {
  550. count++
  551. }
  552. if err := scanner.Err(); err != nil {
  553. fmt.Fprintln(os.Stderr, &#34;reading input:&#34;, err)
  554. }
  555. fmt.Printf(&#34;%d\n&#34;, count)
  556. <span class="comment"></pre>
  557. <p>Output:</p>
  558. <pre class="output">15
  559. </pre>
  560. </div>
  561. </div>
  562. <h3 id="NewScanner">func <a href="http://localhost:6060/src/bufio/scan.go?s=3594:3631#L71">NewScanner</a></h3>
  563. <pre>func NewScanner(r <a href="../io/index.html">io</a>.<a href="../io/index.html#Reader">Reader</a>) *<a href="index.html#Scanner">Scanner</a></pre>
  564. <p>
  565. NewScanner returns a new Scanner to read from r.
  566. The split function defaults to ScanLines.
  567. </p>
  568. <h3 id="Scanner.Buffer">func (*Scanner) <a href="http://localhost:6060/src/bufio/scan.go?s=8759:8804#L247">Buffer</a></h3>
  569. <pre>func (s *<a href="index.html#Scanner">Scanner</a>) Buffer(buf []<a href="../builtin/index.html#byte">byte</a>, max <a href="../builtin/index.html#int">int</a>)</pre>
  570. <p>
  571. Buffer sets the initial buffer to use when scanning and the maximum
  572. size of buffer that may be allocated during scanning. The maximum
  573. token size is the larger of max and cap(buf). If max &lt;= cap(buf),
  574. Scan will use this buffer only and do no allocation.
  575. </p>
  576. <p>
  577. By default, Scan uses an internal buffer and sets the
  578. maximum token size to MaxScanTokenSize.
  579. </p>
  580. <p>
  581. Buffer panics if it is called after scanning has started.
  582. </p>
  583. <h3 id="Scanner.Bytes">func (*Scanner) <a href="http://localhost:6060/src/bufio/scan.go?s=4092:4124#L90">Bytes</a></h3>
  584. <pre>func (s *<a href="index.html#Scanner">Scanner</a>) Bytes() []<a href="../builtin/index.html#byte">byte</a></pre>
  585. <p>
  586. Bytes returns the most recent token generated by a call to Scan.
  587. The underlying array may point to data that will be overwritten
  588. by a subsequent call to Scan. It does no allocation.
  589. </p>
  590. <h3 id="Scanner.Err">func (*Scanner) <a href="http://localhost:6060/src/bufio/scan.go?s=3814:3843#L80">Err</a></h3>
  591. <pre>func (s *<a href="index.html#Scanner">Scanner</a>) Err() <a href="../builtin/index.html#error">error</a></pre>
  592. <p>
  593. Err returns the first non-EOF error that was encountered by the Scanner.
  594. </p>
  595. <h3 id="Scanner.Scan">func (*Scanner) <a href="http://localhost:6060/src/bufio/scan.go?s=5433:5462#L118">Scan</a></h3>
  596. <pre>func (s *<a href="index.html#Scanner">Scanner</a>) Scan() <a href="../builtin/index.html#bool">bool</a></pre>
  597. <p>
  598. Scan advances the Scanner to the next token, which will then be
  599. available through the Bytes or Text method. It returns false when the
  600. scan stops, either by reaching the end of the input or an error.
  601. After Scan returns false, the Err method will return any error that
  602. occurred during scanning, except that if it was io.EOF, Err
  603. will return nil.
  604. Scan panics if the split function returns 100 empty tokens without
  605. advancing the input. This is a common error mode for scanners.
  606. </p>
  607. <h3 id="Scanner.Split">func (*Scanner) <a href="http://localhost:6060/src/bufio/scan.go?s=9072:9112#L259">Split</a></h3>
  608. <pre>func (s *<a href="index.html#Scanner">Scanner</a>) Split(split <a href="index.html#SplitFunc">SplitFunc</a>)</pre>
  609. <p>
  610. Split sets the split function for the Scanner.
  611. The default split function is ScanLines.
  612. </p>
  613. <p>
  614. Split panics if it is called after scanning has started.
  615. </p>
  616. <h3 id="Scanner.Text">func (*Scanner) <a href="http://localhost:6060/src/bufio/scan.go?s=4262:4293#L96">Text</a></h3>
  617. <pre>func (s *<a href="index.html#Scanner">Scanner</a>) Text() <a href="../builtin/index.html#string">string</a></pre>
  618. <p>
  619. Text returns the most recent token generated by a call to Scan
  620. as a newly allocated string holding its bytes.
  621. </p>
  622. <h2 id="SplitFunc">type <a href="http://localhost:6060/src/bufio/scan.go?s=2770:2853#L50">SplitFunc</a></h2>
  623. <pre>type SplitFunc func(data []<a href="../builtin/index.html#byte">byte</a>, atEOF <a href="../builtin/index.html#bool">bool</a>) (advance <a href="../builtin/index.html#int">int</a>, token []<a href="../builtin/index.html#byte">byte</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
  624. <p>
  625. SplitFunc is the signature of the split function used to tokenize the
  626. input. The arguments are an initial substring of the remaining unprocessed
  627. data and a flag, atEOF, that reports whether the Reader has no more data
  628. to give. The return values are the number of bytes to advance the input
  629. and the next token to return to the user, plus an error, if any. If the
  630. data does not yet hold a complete token, for instance if it has no newline
  631. while scanning lines, SplitFunc can return (0, nil, nil) to signal the
  632. Scanner to read more data into the slice and try again with a longer slice
  633. starting at the same point in the input.
  634. </p>
  635. <p>
  636. If the returned error is non-nil, scanning stops and the error
  637. is returned to the client.
  638. </p>
  639. <p>
  640. The function is never called with an empty data slice unless atEOF
  641. is true. If atEOF is true, however, data may be non-empty and,
  642. as always, holds unprocessed text.
  643. </p>
  644. <h2 id="Writer">type <a href="http://localhost:6060/src/bufio/bufio.go?s=13089:13158#L501">Writer</a></h2>
  645. <pre>type Writer struct {
  646. <span class="comment">// contains filtered or unexported fields</span>
  647. }</pre>
  648. <p>
  649. Writer implements buffering for an io.Writer object.
  650. If an error occurs writing to a Writer, no more data will be
  651. accepted and all subsequent writes will return the error.
  652. After all data has been written, the client should call the
  653. Flush method to guarantee all data has been forwarded to
  654. the underlying io.Writer.
  655. </p>
  656. <div id="example_Writer" class="toggle">
  657. <div class="collapsed">
  658. <p class="exampleHeading toggleButton"><span class="text">Example</span></p>
  659. </div>
  660. <div class="expanded">
  661. <p class="exampleHeading toggleButton"><span class="text">Example</span></p>
  662. <p>Code:</p>
  663. <pre class="code">w := bufio.NewWriter(os.Stdout)
  664. fmt.Fprint(w, &#34;Hello, &#34;)
  665. fmt.Fprint(w, &#34;world!&#34;)
  666. w.Flush() <span class="comment">// Don&#39;t forget to flush!</span>
  667. <span class="comment"></pre>
  668. <p>Output:</p>
  669. <pre class="output">Hello, world!
  670. </pre>
  671. </div>
  672. </div>
  673. <h3 id="NewWriter">func <a href="http://localhost:6060/src/bufio/bufio.go?s=13673:13708#L527">NewWriter</a></h3>
  674. <pre>func NewWriter(w <a href="../io/index.html">io</a>.<a href="../io/index.html#Writer">Writer</a>) *<a href="index.html#Writer">Writer</a></pre>
  675. <p>
  676. NewWriter returns a new Writer whose buffer has the default size.
  677. </p>
  678. <h3 id="NewWriterSize">func <a href="http://localhost:6060/src/bufio/bufio.go?s=13354:13403#L511">NewWriterSize</a></h3>
  679. <pre>func NewWriterSize(w <a href="../io/index.html">io</a>.<a href="../io/index.html#Writer">Writer</a>, size <a href="../builtin/index.html#int">int</a>) *<a href="index.html#Writer">Writer</a></pre>
  680. <p>
  681. NewWriterSize returns a new Writer whose buffer has at least the specified
  682. size. If the argument io.Writer is already a Writer with large enough
  683. size, it returns the underlying Writer.
  684. </p>
  685. <h3 id="Writer.Available">func (*Writer) <a href="http://localhost:6060/src/bufio/bufio.go?s=14467:14499#L569">Available</a></h3>
  686. <pre>func (b *<a href="index.html#Writer">Writer</a>) Available() <a href="../builtin/index.html#int">int</a></pre>
  687. <p>
  688. Available returns how many bytes are unused in the buffer.
  689. </p>
  690. <h3 id="Writer.Buffered">func (*Writer) <a href="http://localhost:6060/src/bufio/bufio.go?s=14617:14648#L572">Buffered</a></h3>
  691. <pre>func (b *<a href="index.html#Writer">Writer</a>) Buffered() <a href="../builtin/index.html#int">int</a></pre>
  692. <p>
  693. Buffered returns the number of bytes that have been written into the current buffer.
  694. </p>
  695. <h3 id="Writer.Flush">func (*Writer) <a href="http://localhost:6060/src/bufio/bufio.go?s=13998:14028#L540">Flush</a></h3>
  696. <pre>func (b *<a href="index.html#Writer">Writer</a>) Flush() <a href="../builtin/index.html#error">error</a></pre>
  697. <p>
  698. Flush writes any buffered data to the underlying io.Writer.
  699. </p>
  700. <h3 id="Writer.ReadFrom">func (*Writer) <a href="http://localhost:6060/src/bufio/bufio.go?s=16620:16679#L667">ReadFrom</a></h3>
  701. <pre>func (b *<a href="index.html#Writer">Writer</a>) ReadFrom(r <a href="../io/index.html">io</a>.<a href="../io/index.html#Reader">Reader</a>) (n <a href="../builtin/index.html#int64">int64</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
  702. <p>
  703. ReadFrom implements io.ReaderFrom.
  704. </p>
  705. <h3 id="Writer.Reset">func (*Writer) <a href="http://localhost:6060/src/bufio/bufio.go?s=13862:13897#L533">Reset</a></h3>
  706. <pre>func (b *<a href="index.html#Writer">Writer</a>) Reset(w <a href="../io/index.html">io</a>.<a href="../io/index.html#Writer">Writer</a>)</pre>
  707. <p>
  708. Reset discards any unflushed buffered data, clears any error, and
  709. resets b to write its output to w.
  710. </p>
  711. <h3 id="Writer.Write">func (*Writer) <a href="http://localhost:6060/src/bufio/bufio.go?s=14841:14893#L578">Write</a></h3>
  712. <pre>func (b *<a href="index.html#Writer">Writer</a>) Write(p []<a href="../builtin/index.html#byte">byte</a>) (nn <a href="../builtin/index.html#int">int</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
  713. <p>
  714. Write writes the contents of p into the buffer.
  715. It returns the number of bytes written.
  716. If nn &lt; len(p), it also returns an error explaining
  717. why the write is short.
  718. </p>
  719. <h3 id="Writer.WriteByte">func (*Writer) <a href="http://localhost:6060/src/bufio/bufio.go?s=15317:15357#L603">WriteByte</a></h3>
  720. <pre>func (b *<a href="index.html#Writer">Writer</a>) WriteByte(c <a href="../builtin/index.html#byte">byte</a>) <a href="../builtin/index.html#error">error</a></pre>
  721. <p>
  722. WriteByte writes a single byte.
  723. </p>
  724. <h3 id="Writer.WriteRune">func (*Writer) <a href="http://localhost:6060/src/bufio/bufio.go?s=15603:15659#L617">WriteRune</a></h3>
  725. <pre>func (b *<a href="index.html#Writer">Writer</a>) WriteRune(r <a href="../builtin/index.html#rune">rune</a>) (size <a href="../builtin/index.html#int">int</a>, err <a href="../builtin/index.html#error">error</a>)</pre>
  726. <p>
  727. WriteRune writes a single Unicode code point, returning
  728. the number of bytes written and any error.
  729. </p>
  730. <h3 id="Writer.WriteString">func (*Writer) <a href="http://localhost:6060/src/bufio/bufio.go?s=16291:16342#L648">WriteString</a></h3>
  731. <pre>func (b *<a href="index.html#Writer">Writer</a>) WriteString(s <a href="../builtin/index.html#string">string</a>) (<a href="../builtin/index.html#int">int</a>, <a href="../builtin/index.html#error">error</a>)</pre>
  732. <p>
  733. WriteString writes a string.
  734. It returns the number of bytes written.
  735. If the count is less than len(s), it also returns an error explaining
  736. why the write is short.
  737. </p>
  738. <div id="footer">
  739. Build version go1.6.<br>
  740. Except as <a href="https://developers.google.com/site-policies#restrictions">noted</a>,
  741. the content of this page is licensed under the
  742. Creative Commons Attribution 3.0 License,
  743. and code is licensed under a <a href="http://localhost:6060/LICENSE">BSD license</a>.<br>
  744. <a href="http://localhost:6060/doc/tos.html">Terms of Service</a> |
  745. <a href="http://www.google.com/intl/en/policies/privacy/">Privacy Policy</a>
  746. </div>
  747. </div><!-- .container -->
  748. </div><!-- #page -->
  749. <!-- TODO(adonovan): load these from <head> using "defer" attribute? -->
  750. <script type="text/javascript" src="../../lib/godoc/jquery.js"></script>
  751. <script type="text/javascript" src="../../lib/godoc/jquery.treeview.js"></script>
  752. <script type="text/javascript" src="../../lib/godoc/jquery.treeview.edit.js"></script>
  753. <script type="text/javascript" src="../../lib/godoc/godocs.js"></script>
  754. </body>
  755. </html>