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.3k PHP : How to handle URI or URL with non-ASCII characters such as Chinese/Japanese/Korean(CJK) ?
+17.6k Convert JSON to CSV in Golang
+48.1k Golang : How to convert JSON string to map and slice
+7.8k Swift : Convert (cast) String to Double
+5.4k Unix/Linux : How to archive and compress entire directory ?
+10.2k Golang : Check a web page existence with HEAD request example
+28.5k Golang : Change a file last modified date and time
+20.2k Golang : How to get own program name during runtime ?
+13.5k Golang : Count number of runes in string
+11.7k Golang : Secure file deletion with wipe example
+10.2k Golang : How to profile or log time spend on execution?
+6.3k WARNING: UNPROTECTED PRIVATE KEY FILE! error message