Golang go/token.Position.String function example
package go/token
String returns a string in one of several forms:
file:line:column valid position with file name
line:column valid position without file name
file invalid position with file name
- invalid position without file name
Golang go/token.Position.String function usage example
Example 1:
func loc(fset *token.FileSet, pos token.Pos) string {
if pos == token.NoPos {
return ""
}
return " at " + fset.Position(pos).String()
}
Example 2:
func (p *printer) internalError(msg ...interface{}) {
if debug {
fmt.Print(p.pos.String() + ": ")
fmt.Println(msg...)
panic("internal error in somefile.go")
}
}
Reference :
Advertisement
Something interesting
Tutorials
+5.4k Golang : Reclaim memory occupied by make() example
+12.3k Golang : Print UTF-8 fonts on image example
+15.3k nginx: [emerg] unknown directive "ssl"
+7.3k Golang : How to iterate a slice without using for loop?
+62.7k Golang : Convert HTTP Response body to string
+8.3k Golang : Auto-generate reply email with text/template package
+5.7k Golang : Error handling methods
+20.5k Golang : Pipe output from one os.Exec(shell command) to another command
+8.3k Useful methods to access blocked websites
+6.9k Golang : Calculate BMI and risk category
+9.6k Javascript : Read/parse JSON data from HTTP response
+19.2k Golang : Delete item from slice based on index/key position