You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I looked through the source code to find out, and it appears to me that in
// Position describes an arbitrary source position
// including the file, line, and column location.
// A Position is valid if the line number is > 0.
//
type Position struct {
Filename string // filename, if any
Offset int // offset, starting at 0
Line int // line number, starting at 1
Column int // column number, starting at 1 (character count)
}
the Column is a byte count, not a character (rune) count. Bytes are much more useful when you're holding a []byte anyway, so that's what I was hoping. Probably docs should be updated.
It might also help here:
To create the Pos value for a specific source offset, first add the
respective file to the current file set (via FileSet.AddFile) 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 obtained by calling
fset.Position(p).
to say "a specific source file offset (measured in bytes)". It may be that token is agnostic about this and the bytes part is imposed by go/scanner, but this is where people will look. Maybe "usually measured in bytes" if that's a concern.
The text was updated successfully, but these errors were encountered:
I looked through the source code to find out, and it appears to me that in
the Column is a byte count, not a character (rune) count. Bytes are much more useful when you're holding a []byte anyway, so that's what I was hoping. Probably docs should be updated.
It might also help here:
to say "a specific source file offset (measured in bytes)". It may be that token is agnostic about this and the bytes part is imposed by go/scanner, but this is where people will look. Maybe "usually measured in bytes" if that's a concern.
The text was updated successfully, but these errors were encountered: