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
+9.4k Golang : Apply Histogram Equalization to color images
+5.7k Golang : ROT32768 (rotate by 0x80) UTF-8 strings example
+7.7k Golang : How to execute code at certain day, hour and minute?
+21.9k Golang : Use TLS version 1.2 and enforce server security configuration over client
+13.9k Golang : Get dimension(width and height) of image file
+13.6k Android Studio : Password input and reveal password example
+11.9k Golang : Convert decimal number(integer) to IPv4 address
+6.1k Golang : Create new color from command line parameters
+22.2k Golang : How to run Golang application such as web server in the background or as daemon?
+13.4k Golang : Increment string example
+6.6k Golang : How to validate ISBN?
+11.9k Golang : How to parse plain email text and process email header?