]> Cypherpunks repositories - gostls13.git/commit
go/token: add (*File).LineStart, which returns Pos for a given line
authorAlan Donovan <adonovan@google.com>
Fri, 7 Sep 2018 13:54:38 +0000 (09:54 -0400)
committerAlan Donovan <adonovan@google.com>
Mon, 10 Sep 2018 18:29:25 +0000 (18:29 +0000)
commit0f72e79856d246af85c449f9e5a357ba751cd234
treee28876ef1b097c9b7a13bf740b5f4c9a9e333223
parent12c5ca90a00768c6ad5f6d83f7c37964a30256fb
go/token: add (*File).LineStart, which returns Pos for a given line

LineStart returns the position of the start of a given line.
Like MergeLine, it panics if the 1-based line number is invalid.

This function is especially useful in programs that occasionally
handle non-Go files such as assembly but wish to use the token.Pos
mechanism to identify file positions.

Change-Id: I5f774c0690074059553cdb38c0f681f5aafc8da1
Reviewed-on: https://go-review.googlesource.com/134075
Reviewed-by: Robert Griesemer <gri@golang.org>
src/go/token/position.go
src/go/token/position_test.go