package bufio

Import Path
	bufio (on golang.org and go.dev)

Dependency Relation
	imports 5 packages, and imported by 35 packages

Involved Source Files
	d-> bufio.go
	    scan.go

Exported Type Names

type Reader (struct) Reader implements buffering for an io.Reader object. (*T) Buffered() int (*T) Discard(n int) (discarded int, err error) (*T) Peek(n int) ([]byte, error) (*T) Read(p []byte) (n int, err error) (*T) ReadByte() (byte, error) (*T) ReadBytes(delim byte) ([]byte, error) (*T) ReadLine() (line []byte, isPrefix bool, err error) (*T) ReadRune() (r rune, size int, err error) (*T) ReadSlice(delim byte) (line []byte, err error) (*T) ReadString(delim byte) (string, error) (*T) Reset(r io.Reader) (*T) Size() int (*T) UnreadByte() error (*T) UnreadRune() error (*T) WriteTo(w io.Writer) (n int64, err error) *T : compress/flate.Reader *T : image/jpeg.Reader *T : io.ByteReader *T : io.ByteScanner *T : io.Reader *T : io.RuneReader *T : io.RuneScanner *T : io.WriterTo func NewReader(rd io.Reader) *Reader func NewReaderSize(rd io.Reader, size int) *Reader func net/http/httputil.(*ClientConn).Hijack() (c net.Conn, r *Reader) func net/http/httputil.(*ServerConn).Hijack() (net.Conn, *Reader) func NewReadWriter(r *Reader, w *Writer) *ReadWriter func go/internal/gcimporter.FindExportData(r *Reader) (hdr string, err error) func net/http.ReadRequest(b *Reader) (*http.Request, error) func net/http.ReadResponse(r *Reader, req *http.Request) (*http.Response, error) func net/http/httputil.NewClientConn(c net.Conn, r *Reader) *httputil.ClientConn func net/http/httputil.NewProxyClientConn(c net.Conn, r *Reader) *httputil.ClientConn func net/http/httputil.NewServerConn(c net.Conn, r *Reader) *httputil.ServerConn func net/textproto.NewReader(r *Reader) *textproto.Reader
type ReadWriter (struct) ReadWriter stores pointers to a Reader and a Writer. It implements io.ReadWriter. Reader *Reader Writer *Writer (T) Available() int (T) Discard(n int) (discarded int, err error) (T) Flush() error (T) Peek(n int) ([]byte, error) (T) Read(p []byte) (n int, err error) (T) ReadByte() (byte, error) (T) ReadBytes(delim byte) ([]byte, error) (T) ReadFrom(r io.Reader) (n int64, err error) (T) ReadLine() (line []byte, isPrefix bool, err error) (T) ReadRune() (r rune, size int, err error) (T) ReadSlice(delim byte) (line []byte, err error) (T) ReadString(delim byte) (string, error) (T) UnreadByte() error (T) UnreadRune() error (T) Write(p []byte) (nn int, err error) (T) WriteByte(c byte) error (T) WriteRune(r rune) (size int, err error) (T) WriteString(s string) (int, error) (T) WriteTo(w io.Writer) (n int64, err error) T : compress/flate.Reader T : image/jpeg.Reader T : io.ByteReader T : io.ByteScanner T : io.ByteWriter T : io.Reader T : io.ReaderFrom T : io.ReadWriter T : io.RuneReader T : io.RuneScanner T : io.StringWriter T : io.Writer T : io.WriterTo func NewReadWriter(r *Reader, w *Writer) *ReadWriter func net/http.Hijacker.Hijack() (net.Conn, *ReadWriter, error)
type Scanner (struct) Scanner provides a convenient interface for reading data such as a file of newline-delimited lines of text. Successive calls to the Scan method will step through the 'tokens' of a file, skipping the bytes between the tokens. The specification of a token is defined by a split function of type SplitFunc; the default split function breaks the input into lines with line termination stripped. Split functions are defined in this package for scanning a file into lines, bytes, UTF-8-encoded runes, and space-delimited words. The client may instead provide a custom split function. Scanning stops unrecoverably at EOF, the first I/O error, or a token too large to fit in the buffer. When a scan stops, the reader may have advanced arbitrarily far past the last token. Programs that need more control over error handling or large tokens, or must run sequential scans on a reader, should use bufio.Reader instead. (*T) Buffer(buf []byte, max int) (*T) Bytes() []byte (*T) Err() error (*T) Scan() bool (*T) Split(split SplitFunc) (*T) Text() string func NewScanner(r io.Reader) *Scanner
type SplitFunc (func) SplitFunc is the signature of the split function used to tokenize the input. The arguments are an initial substring of the remaining unprocessed data and a flag, atEOF, that reports whether the Reader has no more data to give. The return values are the number of bytes to advance the input and the next token to return to the user, if any, plus an error, if any. Scanning stops if the function returns an error, in which case some of the input may be discarded. Otherwise, the Scanner advances the input. If the token is not nil, the Scanner returns it to the user. If the token is nil, the Scanner reads more data and continues scanning; if there is no more data--if atEOF was true--the Scanner returns. If the data does not yet hold a complete token, for instance if it has no newline while scanning lines, a SplitFunc can return (0, nil, nil) to signal the Scanner to read more data into the slice and try again with a longer slice starting at the same point in the input. The function is never called with an empty data slice unless atEOF is true. If atEOF is true, however, data may be non-empty and, as always, holds unprocessed text. func (*Scanner).Split(split SplitFunc)
type Writer (struct) Writer implements buffering for an io.Writer object. If an error occurs writing to a Writer, no more data will be accepted and all subsequent writes, and Flush, will return the error. After all data has been written, the client should call the Flush method to guarantee all data has been forwarded to the underlying io.Writer. (*T) Available() int (*T) Buffered() int (*T) Flush() error (*T) ReadFrom(r io.Reader) (n int64, err error) (*T) Reset(w io.Writer) (*T) Size() int (*T) Write(p []byte) (nn int, err error) (*T) WriteByte(c byte) error (*T) WriteRune(r rune) (size int, err error) (*T) WriteString(s string) (int, error) *T : io.ByteWriter *T : io.ReaderFrom *T : io.StringWriter *T : io.Writer func NewWriter(w io.Writer) *Writer func NewWriterSize(w io.Writer, size int) *Writer func NewReadWriter(r *Reader, w *Writer) *ReadWriter func net/textproto.NewWriter(w *Writer) *textproto.Writer
Exported Values
var ErrAdvanceTooFar error Errors returned by Scanner.
var ErrBadReadCount error Errors returned by Scanner.
var ErrFinalToken error ErrFinalToken is a special sentinel error value. It is intended to be returned by a Split function to indicate that the token being delivered with the error is the last token and scanning should stop after this one. After ErrFinalToken is received by Scan, scanning stops with no error. The value is useful to stop processing early or when it is necessary to deliver a final empty token. One could achieve the same behavior with a custom error value but providing one here is tidier. See the emptyFinalToken example for a use of this value.
var ErrNegativeAdvance error Errors returned by Scanner.
var ErrTooLong error Errors returned by Scanner.
const MaxScanTokenSize = 65536 MaxScanTokenSize is the maximum size used to buffer a token unless the user provides an explicit buffer with Scanner.Buffer. The actual maximum token size may be smaller as the buffer may need to include, for instance, a newline.
func NewReader(rd io.Reader) *Reader NewReader returns a new Reader whose buffer has the default size.
func NewReaderSize(rd io.Reader, size int) *Reader NewReaderSize returns a new Reader whose buffer has at least the specified size. If the argument io.Reader is already a Reader with large enough size, it returns the underlying Reader.
func NewReadWriter(r *Reader, w *Writer) *ReadWriter NewReadWriter allocates a new ReadWriter that dispatches to r and w.
func NewScanner(r io.Reader) *Scanner NewScanner returns a new Scanner to read from r. The split function defaults to ScanLines.
func NewWriter(w io.Writer) *Writer NewWriter returns a new Writer whose buffer has the default size.
func NewWriterSize(w io.Writer, size int) *Writer NewWriterSize returns a new Writer whose buffer has at least the specified size. If the argument io.Writer is already a Writer with large enough size, it returns the underlying Writer.
func ScanBytes(data []byte, atEOF bool) (advance int, token []byte, err error) ScanBytes is a split function for a Scanner that returns each byte as a token.
func ScanLines(data []byte, atEOF bool) (advance int, token []byte, err error) ScanLines is a split function for a Scanner that returns each line of text, stripped of any trailing end-of-line marker. The returned line may be empty. The end-of-line marker is one optional carriage return followed by one mandatory newline. In regular expression notation, it is `\r?\n`. The last non-empty line of input will be returned even if it has no newline.
func ScanRunes(data []byte, atEOF bool) (advance int, token []byte, err error) ScanRunes is a split function for a Scanner that returns each UTF-8-encoded rune as a token. The sequence of runes returned is equivalent to that from a range loop over the input as a string, which means that erroneous UTF-8 encodings translate to U+FFFD = "\xef\xbf\xbd". Because of the Scan interface, this makes it impossible for the client to distinguish correctly encoded replacement runes from encoding errors.
func ScanWords(data []byte, atEOF bool) (advance int, token []byte, err error) ScanWords is a split function for a Scanner that returns each space-separated word of text, with surrounding spaces deleted. It will never return an empty string. The definition of space is set by unicode.IsSpace.