Golang go/token.FileSet.Position function example

package go/token

Position converts a Pos(1st parameter) in the fileset into a general Position.

Golang go/token.FileSet.Position function usage example

 callExpr, ok := node.(*ast.CallExpr)
 if !ok {
 return true
 }
 ...
 pos := fset.Position(callExpr.Rparen) // <-- here
 methodCall := &methodCall{
 Line:  pos.Line,
 Names: []string{},
 }

References :

https://github.com/revel/revel/blob/master/harness/reflect.go

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

Advertisement