Golang go/token.FileSet type examples

package go/token

A FileSet represents a set of source files. Methods of file sets are synchronized; multiple goroutines may invoke them concurrently.

Golang go/token.FileSet type usage examples

Example 1:

 func loc(fset *token.FileSet, pos token.Pos) string {
 if pos == token.NoPos {
  return ""
 }
 return " at " + fset.Position(pos).String()
 }

Example 2:

 type SourceMapFilter struct {
 Writer io.Writer
 MappingCallback func(generatedLine, generatedColumn int, fileSet *token.FileSet, originalPos token.Pos)
 line int
 column int
 fileSet *token.FileSet
 }

References :

https://github.com/gopherjs/gopherjs/blob/master/compiler/compiler.go

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

Advertisement