Documentation ¶
Overview ¶
Package streampos exports a Writer that tracks (line, column) positions suitable for error messages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer looks for newline characters and constructs a mapping from byte offset ranges to line numbers. It is typically used with a TeeReader to track positions in some input stream.
func (*Writer) Column ¶
Column returns the column number for the given offset. See Position for more information.
func (*Writer) Line ¶
Line returns the line number for the given offset. See Position for more information.
func (*Writer) Position ¶
Position returns the line and column number for the given offset in the underlying data stream. The offset cannot be negative but must be less than Length. Line numbers start at 1 from the beginning of the stream, column numbers start at 1 from the beginning of the line (left to right). Note that column numbers are based on bytes, so '\t' counts as 1 column whereas multi-byte runes count as several.