1
0
mirror of https://github.com/golang/go synced 2024-11-23 15:20:03 -07:00

go/token: document that column positions and file offsets are in bytes

Fixes #9948.

Change-Id: I7b354fccd5e933eeeb2253a66acec050ebff6e41
Reviewed-on: https://go-review.googlesource.com/5611
Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
Robert Griesemer 2015-02-23 10:20:20 -08:00
parent 2b0213d569
commit 96333a7e48

View File

@ -21,7 +21,7 @@ type Position struct {
Filename string // filename, if any Filename string // filename, if any
Offset int // offset, starting at 0 Offset int // offset, starting at 0
Line int // line number, starting at 1 Line int // line number, starting at 1
Column int // column number, starting at 1 (character count) Column int // column number, starting at 1 (byte count)
} }
// IsValid returns true if the position is valid. // IsValid returns true if the position is valid.
@ -56,8 +56,8 @@ func (pos Position) String() string {
// where base and size are specified when adding the file to the file set via // where base and size are specified when adding the file to the file set via
// AddFile. // AddFile.
// //
// To create the Pos value for a specific source offset, first add // To create the Pos value for a specific source offset (measured in bytes),
// the respective file to the current file set (via FileSet.AddFile) // first add the respective file to the current file set using FileSet.AddFile
// and then call File.Pos(offset) for that file. Given a Pos value p // and then call File.Pos(offset) for that file. Given a Pos value p
// for a specific file set fset, the corresponding Position value is // for a specific file set fset, the corresponding Position value is
// obtained by calling fset.Position(p). // obtained by calling fset.Position(p).