Golang go/token.File.Base function example

package go/token

Base returns the base offset of file f as registered with AddFile.

Golang go/token.File.Base function usage example

 func tokenFileContainsPos(f *token.File, pos token.Pos) bool {
 p := int(pos)
 base := f.Base()
 return base <= p && p < base+f.Size()
 }

References :

https://code.google.com/p/go/source/browse/go/loader/util.go?repo=tools

http://golang.org/pkg/go/token/#File.Base

Advertisement