Description

FormatErrorPos formats source to show the position that a (parse) error occurs. When this works, it returns a slice of one or two strings: the source line with the error and if it can find a column position under that, a line indicating the position where the error occurred.

For example, if we have:

source := `split(os.Args ", )")`
errmsg := "1:15: expected ')'"

then PrintErrPos(source, errmsg) returns:

 {
		`split(os.Args ", )")`,
		`-------------^`
 }

If something is wrong parsing the error message or matching it with the source, an empty slice is returned.

FormatErrorPos is referenced in 0 repositories