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
+51.1k Golang : Disable security check for HTTPS(SSL) with bad or expired certificate
+6.5k Golang : Spell checking with ispell example
+6.6k Golang : Totalize or add-up an array or slice example
+14.2k Elastic Search : Mapping date format and sort by date
+9.2k Golang : How to check if a string with spaces in between is numeric?
+26.1k Mac/Linux and Golang : Fix bind: address already in use error
+19k Golang : Padding data for encryption and un-padding data for decryption
+6.1k Golang : How to write backslash in string?
+7.7k Golang : Test if an input is an Armstrong number example
+7.1k Golang : Validate credit card example
+11k Golang : Replace a parameter's value inside a configuration file example
+12.1k Golang : Save webcamera frames to video file