Golang go/token.FileSet.Base function examples

package go/token

Base returns the minimum base offset that must be provided to AddFile when adding the next file.

Golang go/token.FileSet.Base function usage examples

Example 1:

 var src []byte
 var s scanner.Scanner
 fset := token.NewFileSet()
 file := fset.AddFile("", fset.Base(), len(src))

Example 2:

 if util.IsText(src) {
 // only add the file to the file set (for the full text index)
 file = x.fset.AddFile(filename, x.fset.Base(), len(src))
 file.SetLinesForContent(src)
 return
 }

Reference :

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

Advertisement