Golang go/token.File.Line function examples
package go/token
Line returns the line number for the given file position p(1st parameter); p must be a Pos value in that file or NoPos.
Golang go/token.File.Line function usage examples
Example 1:
if file := x.fset.File(p); file != nil {
if base := file.Base(); base <= m[1] && m[1] <= base+file.Size() {
// match [m[0], m[1]) is within the file boundaries
list[found].filename = file.Name()
list[found].line = file.Line(p) // <--- here
found++
}
}
Example 2:
var p *parser
if p.file.Line(p.pos) == p.file.Line(prev) {
// do something
}
Reference :
Advertisement
Something interesting
Tutorials
+6.9k Fix sudo yum hang problem with no output or error messages
+22.7k Golang : Round float to precision example
+4.4k Golang : Valued expressions and functions example
+9.5k Golang : Changing a RGBA image number of channels with OpenCV
+9.5k Golang : Convert(cast) string to int64
+14.5k Golang : Rename directory
+5.7k Golang : Struct field tags and what is their purpose?
+5.8k Golang : List all packages and search for certain package
+33.7k Golang : All update packages with go get command
+4.1k Javascript : Empty an array example
+17.8k Golang : Defer function inside init()
+9.7k Golang : Eroding and dilating image with OpenCV example